Skip to content

Latest commit

 

History

History
154 lines (117 loc) · 5.36 KB

File metadata and controls

154 lines (117 loc) · 5.36 KB
title Quickstart: Choose how you'll use Flatkey
sidebarTitle Quickstart
description Four ways to use Flatkey — the REST API, the OpenAI SDK, the Flatkey CLI, or your coding agent. One key and one model catalog behind all of them.

Flatkey gives you one key and four ways to spend it. All four share the same account, the same balance, and the same model catalog — so the only question is which one fits how you work.

![The four ways to use Flatkey, shown in the Flatkey Console](/images/quickstart/console-choose-how.png) You do not have to choose once and for all. Start with whichever is closest to what you are doing today, and add the others later against the same key.

Before you start

Create a key at console.flatkey.ai/keys. Flatkey keys begin with sk-. Every option below uses that one key, so keep it in an environment variable and out of source control.

Each panel in the Console also lets you pick an existing key instead of creating a new one, and drops it straight into the snippet it shows you.

API for developers

Call any model over plain HTTP with an OpenAI-compatible request. No SDK, no dependencies — if you have an HTTP client, you are ready.

![The API for developers panel, with a ready-to-run request](/images/quickstart/modal-api.png)

The Console builds the request for you: choose a key, choose a model, and copy the snippet in cURL, Node.js, or Python.

curl https://router.flatkey.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $FLATKEY_API_KEY" \
  -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Say hello in one sentence."}]}'
Base URL, authentication, available endpoints, and error handling.

SDKs for developers

Keep the OpenAI SDK you already use and point it at Flatkey. Your request code does not change — only the base URL does.

![The SDKs for developers panel, with the SDK setup](/images/quickstart/modal-sdk.png)

Same idea as above: pick a key and a model, then copy the setup for your language.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["FLATKEY_API_KEY"],
    base_url="https://router.flatkey.ai/v1",
)
Python and Node.js setup, streaming, and tool calling. Route Claude requests through Flatkey the same way.

Flatkey CLI

Generate images and video from your terminal, or let an AI assistant drive the CLI for you.

![The Flatkey CLI panel, showing install, sign in, and first prompt](/images/quickstart/modal-cli.png) ```bash npm i -g @flatkey-ai/cli ``` ```bash flatkey login ``` Ask your AI assistant for what you want, and let it run the CLI:
```text
Use Flatkey CLI to generate a "beautiful sunrise" picture.
```
Commands, JSON output for agents, and error recovery.

Codex & Claude Code

Connect your coding agent once, then use Flatkey from the projects you already have open.

![The Codex and Claude Code panel, with the install command](/images/quickstart/modal-agents.png)

The Console gives you a single install command for macOS, Linux, or Windows. It installs the agent if you do not have it, asks for your key, and writes the configuration for you.

The installer is interactive. It asks whether you want Claude Code or Codex CLI, and it needs Node.js already installed. Manual setup or CC Switch. Route Codex CLI through Flatkey. Configure the desktop app.

Check that it worked

Whichever option you picked, open Usage Logs in the Console after your first request. You should see it listed with the model, token counts, latency, and cost.

Use the Model Name filter in Flatkey Usage Logs

If nothing appears, wait a few seconds and search again, then confirm the API key and base URL the request actually used.

Next steps

Every supported model with live pricing and health. Status codes, response formats, and what to do about them. Streaming, tool calling, and structured output. Submit a task, poll it, and download the MP4.