API Reference v2.4

API Documentation

One unified API

Complete reference for the GrexLabs API platform. Access 139+ AI models from 22+ providers through a single endpoint.

v2.4.0 139+ Models
139+
Models
22+
Providers
99.9%
Uptime
<50ms
Latency

Introduction

The GrexLabs API provides access to 139+ AI models from 22+ providers through a single unified endpoint. Each model includes an authenticity prompt so it responds in-character. All endpoints are OpenAI-compatible.

Base URL: https://www.grexlabs.in/api/v1

GrexLabs is fully OpenAI-compatible. Swap your existing OpenAI base URL with the GrexLabs endpoint and use the same SDK, tools, and libraries you already have.

Authentication

All API requests require an API key passed via the Authorization header:

Authorization: Bearer sk-gl-<your-api-key>

Generate your free API key from the Dashboard.

Keep your API key secure. Never expose it in client-side code or public repositories. Use environment variables for server-side integrations.

Models

GrexLabs offers 139+ models from 22+ providers through a single unified API. Browse the full catalogue or use the quick reference below.

Browse All Models

Flagship Models

gpt-4o
GPT-4o128K
claude-sonnet-4
Claude Sonnet 4200K
gemini-2.5-pro
Gemini 2.5 Pro1M
deepseek-v3
DeepSeek V364K
glm-4.7
GLM 4.7200K
kimi-k3
Kimi K31M
llama-4-maverick
Llama 4 Maverick1M

Vision Models

gpt-4o
GPT-4o128K
claude-sonnet-4-20260514
Claude Sonnet 4200K
gemini-2.5-flash
Gemini 2.5 Flash1M
glm-4v
GLM 4V8K
nova-pro-v1
Nova Pro V1131K

Full model list at GET /api/v1/models or the Models page.

Quick Start

Make your first API call — pick your language below.

curl https://www.grexlabs.in/api/v1/chat/completions \
  -H "Authorization: Bearer sk-gl-<your-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "hy3-free",
    "messages": [
      {"role": "user", "content": "Hello! What can you do?"}
    ],
    "temperature": 0.7,
    "max_tokens": 1024
  }'
import requests

response = requests.post(
    "https://www.grexlabs.in/api/v1/chat/completions",
    headers={
        "Authorization": "Bearer sk-gl-<your-key>",
        "Content-Type": "application/json"
    },
    json={
        "model": "hy3-free",
        "messages": [
            {"role": "user", "content": "Hello! What can you do?"}
        ],
        "temperature": 0.7,
        "max_tokens": 1024
    }
)

data = response.json()
print(data["choices"][0]["message"]["content"])
const response = await fetch(
  "https://www.grexlabs.in/api/v1/chat/completions",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk-gl-<your-key>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "hy3-free",
      messages: [
        { role: "user", content: "Hello! What can you do?" }
      ],
      temperature: 0.7,
      max_tokens: 1024
    })
  }
);

const data = await response.json();
console.log(data.choices[0].message.content);
<?php
$ch = curl_init("https://www.grexlabs.in/api/v1/chat/completions");
$payload = json_encode([
    "model" => "hy3-free",
    "messages" => [
        ["role" => "user", "content" => "Hello! What can you do?"]
    ],
    "temperature" => 0.7,
    "max_tokens" => 1024
]);
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $payload,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer sk-gl-<your-key>",
        "Content-Type: application/json"
    ],
    CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
echo $data["choices"][0]["message"]["content"];
curl_close($ch);
require "net/http"
require "json"

uri = URI("https://www.grexlabs.in/api/v1/chat/completions")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer sk-gl-<your-key>"
request["Content-Type"] = "application/json"
request.body = {
  model: "hy3-free",
  messages: [{ role: "user", content: "Hello!" }],
  temperature: 0.7,
  max_tokens: 1024
}.to_json

response = http.request(request)
puts JSON.parse(response.body)["choices"][0]["message"]["content"]
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    body := map[string]interface{}{
        "model": "hy3-free",
        "messages": []map[string]string{
            {"role": "user", "content": "Hello!"},
        },
        "temperature": 0.7,
        "max_tokens": 1024,
    }
    jsonBody, _ := json.Marshal(body)
    req, _ := http.NewRequest("POST",
        "https://www.grexlabs.in/api/v1/chat/completions",
        bytes.NewBuffer(jsonBody))
    req.Header.Set("Authorization", "Bearer sk-gl-<your-key>")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    fmt.Println(result["choices"].([]interface{})[0].(map[string]interface{})["message"].(map[string]interface{})["content"])
}
use reqwest;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    let body = json!({
        "model": "hy3-free",
        "messages": [{"role": "user", "content": "Hello!"}],
        "temperature": 0.7,
        "max_tokens": 1024
    });
    let resp = client
        .post("https://www.grexlabs.in/api/v1/chat/completions")
        .header("Authorization", "Bearer sk-gl-<your-key>")
        .header("Content-Type", "application/json")
        .json(&body)
        .send().await?
        .json::<serde_json::Value>().await?;
    println!("{}", resp["choices"][0]["message"]["content"].as_str().unwrap());
    Ok(())
}
import java.net.URI;
import java.net.http.*;
import com.google.gson.JsonObject;

public class App {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        JsonObject body = new JsonObject();
        body.addProperty("model", "hy3-free");
        JsonObject msg = new JsonObject();
        msg.addProperty("role", "user");
        msg.addProperty("content", "Hello!");
        body.add("messages", new com.google.gson.JsonArray());
        body.getAsJsonArray("messages").add(msg);

        HttpRequest req = HttpRequest.newBuilder()
            .uri(URI.create("https://www.grexlabs.in/api/v1/chat/completions"))
            .header("Authorization", "Bearer sk-gl-<your-key>")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(body.toString()))
            .build();

        HttpResponse<String> res = client.send(req, HttpResponse.BodyHandlers.ofString());
        System.out.println(res.body());
    }
}
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;

var client = new HttpClient();
client.DefaultRequestHeaders.Add(
    "Authorization", "Bearer sk-gl-<your-key>");

var body = new {
    model = "hy3-free",
    messages = new[] { new {
        role = "user", content = "Hello!" } },
    temperature = 0.7,
    max_tokens = 1024
};

var json = JsonConvert.SerializeObject(body);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
    "https://www.grexlabs.in/api/v1/chat/completions", content);
var result = await response.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(result);
Console.WriteLine(data.choices[0].message.content);
import Foundation

let url = URL(string: "https://www.grexlabs.in/api/v1/chat/completions")!
var req = URLRequest(url: url)
req.httpMethod = "POST"
req.setValue("Bearer sk-gl-<your-key>", forHTTPHeaderField: "Authorization")
req.setValue("application/json", forHTTPHeaderField: "Content-Type")

let body: [String: Any] = [
    "model": "hy3-free",
    "messages": [["role": "user", "content": "Hello!"]],
    "temperature": 0.7,
    "max_tokens": 1024
]
req.httpBody = try! JSONSerialization.data(withJSONObject: body)

URLSession.shared.dataTask(with: req) { data, _, _ in
    if let data = data,
       let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
       let choices = json["choices"] as? [[String: Any]],
       let msg = choices.first?["message"] as? [String: Any],
       let content = msg["content"] as? String {
        print(content)
    }
}.resume()

Chat Completions

POST /api/v1/chat/completions Generate a chat completion

Generate a chat completion using any GrexLabs model. Supports text and vision inputs.

Request Body

ParameterTypeRequiredDescription
modelstringRequiredModel ID (e.g., hy3-free, deepseek-v4-flash-free)
messagesarrayRequiredArray of message objects with role and content
temperaturenumberOptionalSampling temperature (0–2, default: 0.7)
max_tokensintegerOptionalMaximum tokens in response (default: 2048)
streambooleanOptionalEnable SSE streaming (default: false)

Response

{
  "id": "sk-gl-1712345678-a1b2c3",
  "object": "chat.completion",
  "created": 1712345678,
  "model": "hy3-free",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! I'm GPT-4o, hosted by GrexLabs Studio..."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 45,
    "total_tokens": 57
  }
}

Streaming

Set stream: true to receive responses as Server-Sent Events (SSE). Each chunk contains a delta with partial content.

curl https://www.grexlabs.in/api/v1/chat/completions \
  -H "Authorization: Bearer sk-gl-<your-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash-free",
    "messages": [{"role": "user", "content": "Tell me a story"}],
    "stream": true
  }'

Events end with data: [DONE]. Use any SSE client library to handle the stream.

Moderation

POST /api/v1/moderate Content safety check

Check content against safety policies. Returns flagged categories with confidence scores.

{
  "input": "Your text to check"
}

API Keys

Rate Limits

GET /api/v1/limits View rate limit tiers
TierRequests / minTokens / minConcurrent
Free60100K5
Pro1,0001M50
Enterprise10,00010M500