OpenAI-Compatible API Endpoint for FreeLLMAPI: Complete Configuration Guide

FreeLLMAPI exposes a single OpenAI-compatible endpoint at the path /v1, making the full base URL http://localhost:3001/v1 by default, which allows any standard OpenAI client library to route requests to free-tier LLM providers using a unified API key.

The tashfeenahmed/freellmapi repository implements this compatibility layer to abstract away the complexity of multiple free-tier providers. By presenting a unified OpenAI-compatible API endpoint, FreeLLMAPI enables developers to use existing OpenAI SDKs and tools without modifying their application code beyond changing the base URL and authentication token.

What Is the OpenAI-Compatible API Endpoint for FreeLLMAPI?

FreeLLMAPI provides a OpenAI-compatible API endpoint mounted at the /v1 path. When the server runs with default configuration, clients should target:


http://localhost:3001/v1

This base URL accepts all standard OpenAI API requests, including chat completions, embeddings, and image generations. According to the repository's README, "Anything that can target an OpenAI-compatible base URL works: set it to http://localhost:3001/v1" to immediately route traffic through FreeLLMAPI's provider pool.

Supported OpenAI-Style Endpoints

FreeLLMAPI mirrors the official OpenAI API surface. The docs/api/01-rest-api.md file documents the following supported endpoints:

  • /v1/chat/completions – Standard chat interface for conversational models
  • /v1/embeddings – Text embedding generation for vector operations
  • /v1/images/generations – Image creation through AI models

All endpoints accept the same JSON payload structures as the official OpenAI API, requiring only the addition of the "model": "auto" parameter to enable FreeLLMAPI's intelligent routing between free-tier providers.

Implementation in Source Code

The OpenAI-compatible functionality is implemented across several key files in the repository:

server/src/routes/proxy.ts implements the central /v1 proxy layer that intercepts incoming OpenAI-style requests and forwards them to appropriate free-tier providers based on availability and rate limits.

server/src/providers/openai-compat.ts handles custom OpenAI-compatible provider configurations, including integrations with Ollama and llama.cpp deployments, ensuring broad compatibility with various hosting setups.

docs/api/01-rest-api.md serves as the definitive reference for all supported OpenAI-style surfaces, documenting request schemas and response formats that match the official OpenAI specification.

Configuring OpenAI SDK Clients

To use FreeLLMAPI with official OpenAI client libraries, configure the base URL and API key parameters.

Node.js SDK Configuration

When using the openai npm package, instantiate the client with the FreeLLMAPI endpoint:

import { OpenAI } from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:3001/v1",   // OpenAI-compatible base URL
  apiKey: "<unified-api-key>",          // Key from the FreeLLMAPI dashboard
});

const response = await client.embeddings.create({
  model: "auto",
  input: "Free LLMAPI provides free-tier models",
});
console.log(response.data[0].embedding);

This configuration routes all SDK methods—including chat.completions.create() and images.generate()—through FreeLLMAPI's provider pool rather than OpenAI's servers.

cURL Examples

For direct HTTP requests, prepend /v1 to all endpoint paths and include the unified API key in the Authorization header.

Chat completions:

curl http://localhost:3001/v1/chat/completions \
  -H "Authorization: Bearer <unified-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
        "model": "auto",
        "messages": [{"role":"user","content":"Hello, world!"}]
      }'

Image generation:

curl http://localhost:3001/v1/images/generations \
  -H "Authorization: Bearer <unified-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
        "prompt": "A futuristic city skyline at sunset",
        "model": "auto",
        "size": "1024x1024"
      }'

Authentication Requirements

All requests to the OpenAI-compatible API endpoint require Bearer token authentication using the unified API key generated in the FreeLLMAPI dashboard. Include this key in the Authorization header as shown in the examples above. The proxy layer in server/src/routes/proxy.ts validates this token before routing requests to downstream providers.

Summary

  • FreeLLMAPI exposes a single OpenAI-compatible base URL at http://localhost:3001/v1 (by default)
  • The endpoint supports standard OpenAI API paths including /v1/chat/completions, /v1/embeddings, and /v1/images/generations
  • Implementation resides primarily in server/src/routes/proxy.ts and server/src/providers/openai-compat.ts
  • Authentication requires a unified API key passed as a Bearer token in the Authorization header
  • Any OpenAI-compatible client library works by changing only the baseURL configuration parameter

Frequently Asked Questions

What is the exact OpenAI-compatible API endpoint URL for FreeLLMAPI?

The exact endpoint is http://localhost:3001/v1 when running the server locally with default settings. This path serves as the base URL for all OpenAI-style API calls, meaning you append specific resource paths like /chat/completions or /embeddings to this base.

Does FreeLLMAPI support all OpenAI API features?

FreeLLMAPI supports the core OpenAI API surfaces documented in docs/api/01-rest-api.md, specifically chat completions, embeddings, and image generations. Advanced features like fine-tuning, file uploads, and assistants may not be available depending on the underlying free-tier providers' capabilities.

How do I authenticate requests to the FreeLLMAPI endpoint?

Authenticate using the unified API key displayed in your FreeLLMAPI dashboard. Pass this key in the Authorization header with the format Bearer <unified-api-key> for every request to any /v1/* endpoint, exactly as you would with a standard OpenAI API key.

Can I use the official OpenAI Python or Node.js SDK with FreeLLMAPI?

Yes. Both the official Python and Node.js OpenAI SDKs work with FreeLLMAPI by setting the base_url (Python) or baseURL (Node.js) parameter to http://localhost:3001/v1 and providing your unified API key as the api_key or apiKey parameter. No other code changes are required.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →