gpt-4.1 — Free API

Created by OpenAI ⭐ Score: 57
github-models/gpt-4-1
🛠️ Function Calling JSON Mode chat

What is gpt-4.1?

GPT-4.1 is OpenAI's mid-tier model available for free through GitHub Models — Microsoft's AI playground for GitHub users. With a 1M-token context window, 32K max output, and OpenAI-native SDK compatibility, it is the most accessible way to use a GPT-4-class model without paying for an OpenAI API key. The free tier is rate-limited to 10 RPM and 50 requests per day, and per-request token caps apply (8K input / 4K output), so it is best suited for prototyping, testing prompts, and lightweight coding tasks rather than production deployment. Requires only a GitHub account — no separate API key signup needed.

Model ID
gpt-4-1
Base URL
https://models.github.ai/inference

gpt-4.1 API Code Example

Paste your API key and run. See the config generator for Claude Code, Cursor, and more tools.

from openai import OpenAI

client = OpenAI(
    base_url="https://models.github.ai/inference",
    api_key="YOUR_API_KEY"
)

response = client.chat.completions.create(
    model="gpt-4-1",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "https://models.github.ai/inference",
  apiKey: "YOUR_API_KEY",
});

const completion = await openai.chat.completions.create({
  model: "gpt-4-1",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(completion.choices[0].message.content);
curl https://models.github.ai/inference/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4-1",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Other Free Models from GitHub Models

More About GitHub Models

How to get an API key, rate limits, platform limitations, and tool configuration — everything you need to set up GitHub Models as a free LLM API backend.

View GitHub Models full guide →