FluxCDN AI in your code: SDKs and frameworks
The official OpenAI SDK in each language, with two changes: the base address and the key. The Anthropic SDKs work with the Anthropic-compatible address. The model id is anything from the models page. The examples read the key from FLUXCDN_API_KEY.
- Address (OpenAI-compatible):
https://ai.fluxcdn.cloud/api/v1- Address (Anthropic-compatible):
https://ai.fluxcdn.cloud/api
Before you start
- Create an API key. On the API keys page press “Create key” and copy the key right away. It starts with
flux_live_and is never shown in full again. - Give agents a key of their own and set a daily or monthly spending limit on it with “Limits”. Agents send request after request by themselves; the limit stops spending you didn't expect.
- Have some credit in the account (Billing).
- In the examples, put your own key where it says
flux_live_YOUR_KEY.
Python (openai)
Step 1:
pip install openaiThe Responses API works too (
client.responses.create(...)), without state:previous_response_idisn't accepted. So doclient.images.generate(...),client.images.edit(...)andclient.audio.speech.create(...), with the catalog's image and speaking models (API reference).main.pyimport os from openai import OpenAI client = OpenAI( base_url="https://ai.fluxcdn.cloud/api/v1", api_key=os.environ["FLUXCDN_API_KEY"], ) reply = client.chat.completions.create( model="anthropic/claude-sonnet-5.5", messages=[{"role": "user", "content": "Hello"}], ) print(reply.choices[0].message.content)
JavaScript / TypeScript (openai)
Step 1:
npm install openaiRuns on Node, Deno, Bun and edge runtimes. Don't put the key in code that reaches your users' browsers; send the request from your own server.
main.tsimport OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://ai.fluxcdn.cloud/api/v1", apiKey: process.env.FLUXCDN_API_KEY, }); const reply = await client.chat.completions.create({ model: "qwen/qwen3-coder", messages: [{ role: "user", content: "Hello" }], }); console.log(reply.choices[0].message.content);
Anthropic SDK
Step 1: The address without
/v1The Anthropic SDKs add
/v1/messagesthemselves, so the address ishttps://ai.fluxcdn.cloud/api. Any id from the catalog works, not only Claude. We accept the key in bothx-api-keyandAuthorization: Bearer.pip install anthropicimport os import anthropic client = anthropic.Anthropic( base_url="https://ai.fluxcdn.cloud/api", api_key=os.environ["FLUXCDN_API_KEY"], ) message = client.messages.create( model="anthropic/claude-sonnet-5.5", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}], ) print(message.content[0].text)
Vercel AI SDK
Step 1:
@ai-sdk/openai-compatibleThis package always calls Chat Completions. If you use
@ai-sdk/openai,openai(...)goes to the Responses API; writeopenai.chat(...)for Chat Completions.npm install ai @ai-sdk/openai-compatibleimport { createOpenAICompatible } from "@ai-sdk/openai-compatible"; import { generateText } from "ai"; const fluxcdn = createOpenAICompatible({ name: "fluxcdn", baseURL: "https://ai.fluxcdn.cloud/api/v1", apiKey: process.env.FLUXCDN_API_KEY, includeUsage: true, }); const { text } = await generateText({ model: fluxcdn("anthropic/claude-sonnet-5.5"), prompt: "Hello", });
LangChain
Step 1:
ChatOpenAIwith the FluxCDN addressChatOpenAIswitches to the Responses API when you passreasoningor OpenAI's built-in tools. To stay on Chat Completions, setuse_responses_api=False(in JS:useResponsesApi: false).pip install langchain-openaiimport os from langchain_openai import ChatOpenAI llm = ChatOpenAI( model="deepseek/deepseek-v4-pro", base_url="https://ai.fluxcdn.cloud/api/v1", api_key=os.environ["FLUXCDN_API_KEY"], ) print(llm.invoke("Hello").content)
LlamaIndex
Step 1:
OpenAILikewithis_chat_model=TrueOpenAILikedefaultsis_chat_modelto off, which calls the old/completionspath we don't have. Turn both options on.pip install llama-index-llms-openai-likeimport os from llama_index.llms.openai_like import OpenAILike llm = OpenAILike( model="openai/gpt-5.5", api_base="https://ai.fluxcdn.cloud/api/v1", api_key=os.environ["FLUXCDN_API_KEY"], context_window=400000, is_chat_model=True, is_function_calling_model=True, ) print(llm.complete("Hello"))
LiteLLM
Step 1:
openai/before the idLiteLLM removes the first part of the id and sends the rest, so write
openai/anthropic/claude-sonnet-5.5. A bareanthropic/prefix sends LiteLLM to Anthropic's server.pip install litellmimport os import litellm reply = litellm.completion( model="openai/anthropic/claude-sonnet-5.5", api_base="https://ai.fluxcdn.cloud/api/v1", api_key=os.environ["FLUXCDN_API_KEY"], messages=[{"role": "user", "content": "Hello"}], ) print(reply.choices[0].message.content)
PHP (openai-php/client)
Step 1:
composer require openai-php/clientPHP 8.2 or later.
index.php<?php $client = OpenAI::factory() ->withApiKey(getenv('FLUXCDN_API_KEY')) ->withBaseUri('https://ai.fluxcdn.cloud/api/v1') ->make(); $reply = $client->chat()->create([ 'model' => 'moonshotai/kimi-k3.1-pro', 'messages' => [['role' => 'user', 'content' => 'Hello']], ]); echo $reply->choices[0]->message->content;
Go (openai-go)
Step 1:
go get github.com/openai/openai-go/v3main.goclient := openai.NewClient( option.WithBaseURL("https://ai.fluxcdn.cloud/api/v1"), option.WithAPIKey(os.Getenv("FLUXCDN_API_KEY")), ) reply, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{ Model: "anthropic/claude-sonnet-5.5", Messages: []openai.ChatCompletionMessageParamUnion{openai.UserMessage("Hello")}, }) if err == nil { fmt.Println(reply.Choices[0].Message.Content) }
.NET (OpenAI)
Step 1:
dotnet add package OpenAIProgram.csusing OpenAI; using OpenAI.Chat; using System.ClientModel; ChatClient client = new( model: "anthropic/claude-sonnet-5.5", credential: new ApiKeyCredential(Environment.GetEnvironmentVariable("FLUXCDN_API_KEY")), options: new OpenAIClientOptions { Endpoint = new Uri("https://ai.fluxcdn.cloud/api/v1") }); ChatCompletion reply = client.CompleteChat("Hello"); Console.WriteLine(reply.Content[0].Text);
Java (openai-java)
Step 1:
com.openai:openai-javaMain.javaOpenAIClient client = OpenAIOkHttpClient.builder() .apiKey(System.getenv("FLUXCDN_API_KEY")) .baseUrl("https://ai.fluxcdn.cloud/api/v1") .build(); ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() .model("anthropic/claude-sonnet-5.5") .addUserMessage("Hello") .build(); ChatCompletion reply = client.chat().completions().create(params); System.out.println(reply.choices().get(0).message().content().orElse(""));
curl
Step 1: Without an SDK
Terminalcurl https://ai.fluxcdn.cloud/api/v1/chat/completions \ -H "Authorization: Bearer $FLUXCDN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek/deepseek-v4-flash", "messages": [{"role": "user", "content": "Hello"}] }'
Check it works
Step 1: List the models
With a valid key you get a list of ids back; without one, a 401.
Terminalcurl -s https://ai.fluxcdn.cloud/api/v1/models -H "Authorization: Bearer $FLUXCDN_API_KEY"Step 2: What each request cost
Every answer carries
x-fluxcdn-request-id, and answers that aren't streamed carryx-fluxcdn-cost-micros(the cost in millionths of a dollar). Every request is also under Activity in the console.
Troubleshooting
- LlamaIndex answers 404
- Set
is_chat_model=True. - Error 401 or
invalid_api_key - The key wasn't copied whole, was revoked, or went in the wrong field. It starts with
flux_live_and has no spaces. If the tool reads it from an environment variable, open a new terminal or window after setting it. - Error 402,
insufficient_credit(in Codex:insufficient_quota) although you have credit - Before each request, the most it could cost is set aside from your credit. When the answer ends, only the real cost is taken and the rest is released. A tool that asks for a very long output on every request sets aside a large amount. Lower the tool's output limit (for example to 32000 tokens) or add credit.
- Error 404 or
model_not_found - The model id must be exactly as on the models page, with the maker's prefix:
anthropic/claude-sonnet-5.5, notclaude-sonnet-5.5. Lower case and dots matter. Copy the id rather than typing it. - A 404 that doesn't mention the model
- The base address is wrong. Most tools want
https://ai.fluxcdn.cloud/api/v1and add the rest themselves; don't write/chat/completionstwice and don't leave out/v1. See the which address table. - An error about
previous_response_idor OpenAI's built-in tools (web search, file search, code interpreter) - Some tools switch to the Responses API without saying so. FluxCDN has it, but without memory (the whole conversation is sent each time) and without the tools that run on OpenAI's servers. Set the tool to Chat Completions: in n8n turn off Use Responses API, in Continue
useResponsesApi: false, in the Vercel AI SDKopenai.chat(...), in LangChainuse_responses_api=False. - A CORS error or “Network error” in browser apps
- FluxCDN answers requests made straight from a browser, so CORS is no longer in the way. If you still see this error, check the address and the key; a browser sometimes shows a 401 or 404 as a network error. Never put your key in a page other people open.
- Error 429:
rate_limit_exceededorbudget_exceeded - Either requests per minute went over the limit (wait a little; most tools retry by themselves), or this key's spending today or this month reached its limit. See it on API keys under “Limits”.
- Error 502, 503, 504 or 529
- The model's service was briefly unavailable. Send again; most tools do it themselves. A request that fails before answering costs nothing. If it lasts, switch to another model for a while.
Limits
embeddingsandaudio.transcriptionsend in a 404. Speech is made as WAV or PCM only (mp3 and the like: a 400), and images come back asb64_jsononly (response_format="url": a 400) (API reference).

