Frameworks
Any framework that speaks OpenAI chat.completions works on two settings: the base URL and the model id. Each one's configuration, and where it tends to snag.
LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="qwen3.8-flash-next-whitehacker", base_url="https://api.kotoba.cloud/v1",
api_key=os.environ["KOTOBA_API_TOKEN"], max_tokens=2048)
llm.invoke("Summarize the auth flow in this file: ...")
streaming=True works (the answer arrives as one chunk). bind_tools works on native tool_calls.
LlamaIndex
from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(model="qwen3.8-flash-next-whitehacker", api_base="https://api.kotoba.cloud/v1",
api_key=os.environ["KOTOBA_API_TOKEN"], is_chat_model=True, max_tokens=2048)
Use OpenAILike, not OpenAI (it does not reject an unknown model id).
Vercel AI SDK
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
const kotoba = createOpenAI({ baseURL: "https://api.kotoba.cloud/v1", apiKey: process.env.KOTOBA_API_TOKEN });
const { text } = await generateText({ model: kotoba.chat("qwen3.8-flash-next-whitehacker"), maxTokens: 2048, prompt: "..." });
Use kotoba.chat(...): the default kotoba(...) may pick the Responses API, which is 405 here.
OpenAI Agents SDK
from agents import Agent, Runner, OpenAIChatCompletionsModel, set_tracing_disabled
from openai import AsyncOpenAI
client = AsyncOpenAI(base_url="https://api.kotoba.cloud/v1", api_key=os.environ["KOTOBA_API_TOKEN"])
set_tracing_disabled(True) # tracing posts to OpenAI, not here
agent = Agent(name="reviewer", model=OpenAIChatCompletionsModel(model="qwen3.8-flash-next-whitehacker", openai_client=client))
Runner.run_sync(agent, "Review src/auth.py")
Name OpenAIChatCompletionsModel explicitly (the default is the Responses API).
LiteLLM
import litellm
litellm.completion(model="openai/qwen3.8-flash-next-whitehacker", api_base="https://api.kotoba.cloud/v1",
api_key=os.environ["KOTOBA_API_TOKEN"], max_tokens=2048,
messages=[{"role": "user", "content": "..."}])
The openai/ prefix pins chat.completions. For proxy mode see the Anthropic SDK page.
Common snags
- n > 1, logprobs, embeddings and image input are not offered.
- Set max_tokens explicitly (the default 2,048 includes reasoning).
- Red-team models need verification and a scope; read the first 403's reason at /v1/research/status.
- Resending the identical request re-attaches to the same job (never charged twice) — retries are safe.