How to actually call the Runware API correctly for any task - inspect the model's schema, send the right fields, run synchronously for images or asynchronous...
Design & media
Llm Agent
Try itBuild a chat, reasoning, or tool-calling agent on top of Runware-hosted LLMs. Use when the user says "make an agent that can call my functions", "let the mod...
What it does
Build a chat, reasoning, or tool-calling agent on top of Runware-hosted LLMs. Use when the user says "make an agent that can call my functions", "let the model use these tools", "wire up an LLM over my API", "chat assistant with function calling", "give the model access to my database/search", or wants multi-step reasoning that runs the user's own code. Covers the OpenAI-compatible chat-completions + tool-calling loop, not the imageInference task shape.
The skill document
LLM agent
Build a conversational or agentic LLM over your own functions using Runware-hosted models. The model reasons, decides when to call the tools you define, reads what they return, and answers with that data in hand. Runware exposes an OpenAI-compatible endpoint, so this is the standard chat-completions + tool-calling format, not the imageInference task shape the image skills use.
Inputs to collect
- The job: plain chat/reasoning, or tool-calling over the user's own functions.
- The tools (if agentic): each function's name, what it does, its arguments, and how the user runs it. The model never touches the systems directly. It only sees the schemas you hand it and the JSON they return.
- The system prompt: the agent's role and how eagerly it should act ("gather context before acting" vs "act immediately").
- Constraints: latency/cost target, context-window needs, whether reasoning depth matters.
Models
Address by AIR. Confirm each is live and inspect its schema via runware-models + runware-run before calling. Never hardcode a stale pick.
- Default flagship: Gemini 3.1 Pro (
google:gemini@3.1-pro). Strongest reasoning and instruction-following, ~1M-token context. Best general agent brain. - Claude Opus 4.8 (
anthropic:claude@opus-4.8). Premium reasoning and long-horizon tool use. - Claude Sonnet 4.6 (
anthropic:claude@sonnet-4.6). Fast, cheaper Claude tier for high-volume or latency-sensitive agents. - Kimi K2.6 (slug
moonshotai-kimi-k2-6, AIRmoonshotai:kimi@k2.6). Open frontier model built for long-horizon, tool-rich agentic workflows. The tool-calling guide is grounded on it. - Qwen3.5-397B (
alibaba:qwen@3.5-397b). Large MoE reasoner with ultra-long context, strong on coding and agent tasks.
Route by sub-task, not by brand: pick reasoning depth and context window for the job, then drop to a faster tier for cheap or high-volume calls. All five carry io:text-to-text.
Workflow
This is text, not media, so it runs over the OpenAI-compatible endpoint, not imageInference.
- Point an OpenAI client at Runware. Base URL
https://api.runware.ai/v1, your Runware API key, and setmodelto the AIR (or slug). Existing OpenAI agent code and frameworks work unchanged. See the platform endpoint docs at/docs/platform/openai. - Describe each tool as a JSON schema under
tools:{ "type": "function", "function": { name, description, parameters } }. Constrain arguments tightly (enum,required). - Send the conversation (
messageswithsystem+user) plustools. Settool_choice(defaultauto). - Run the loop. Read
response.choices[0].message. Iffinish_reasonistool_calls, the assistantcontentis null and calls live inmessage.tool_calls. For each call: parsefunction.arguments(a JSON string, not an object), run the function, and append onetoolmessage whosetool_call_idmatches the call'sid. Append the assistant message too. Repeat until the model returns no tool calls (finish_reason: "stop"). - Bound the loop. Cap iterations and stop with a clear error at the cap. Do not rely on the model to always finish on its own.
See references/examples.md for worked request/response recipes: a basic chat completion, a single tool-call loop, and parallel tool calls in OpenAI chat-completions format.
Technique
- One call answers one question. A loop answers a task. The model often calls more tools after seeing the first results. The whole protocol is: send the conversation, append whatever comes back, repeat until no more tool calls. The round that a single call can't reach is the model reading earlier results and choosing a new action from them.
- Three details carry the round-trip. A
tool_callsfinish means there is no text to show yet.argumentsis a JSON-encoded string you must parse. Yourtoolreply'stool_call_idmust equal the call'sid, and that pairing is how the model matches your result to its request. - Echo every tool call back into history. Append both the assistant message that requested the call and your
toolreply. Dropping the assistant message breaks thetool_call_idpairing and the next request errors. - Return errors as tool results, not exceptions. On a tool failure send
{ "error": "..." }back as thetoolmessage so the model can read it and adjust. A thrown exception just ends the loop. - Parallel tool calls come back in one message. When the model needs several independent pieces of information, it returns multiple entries in one
tool_callsarray instead of one round at a time. The loop already handles this: iterate every entry, append onetoolmessage per call. Because each result is matched by its owntool_call_id, you can run independent calls concurrently and append results in any order. - Set the action threshold in the system prompt. Whether the model gathers context before acting or acts immediately is shaped by lines like "inspect health and logs before taking action." Tighten or loosen that to match the autonomy you want.
- Design tools the model can use well. Name and description are a tool's entire interface. Name functions like API endpoints (
get_service_health,search_logs), nothandlerordoStuff. Treat the description as instructions for choosing between tools mid-conversation. Return compact JSON objects with named fields, not prose or large blobs. Keep the set small: a handful of well-scoped tools beats a large overlapping catalog.
Parameters that matter
model: the AIR (or slug). Confirm it'slivefirst.messages: the conversation. Keep stable parts (system prompt + tool defs) as a fixed prefix to maximize Runware's prompt cache. Watchusage.prompt_tokens_details.cached_tokensclimb across rounds on long conversations.tools: array of function schemas.enumandrequiredare the difference between a clean call and a malformed one.tool_choice:"auto"(default, model decides),"none"(text only, no tools),"required"(must call at least one tool), or{ "type": "function", "function": { "name": "..." } }(must call the named one, useful when the action is decided and you only need arguments filled). Naming a function guarantees that call but the model may still issue others it judges necessary. Expose only that one tool if you need exactly one call.temperature,max_completion_tokens: standard OpenAI knobs. Lower temperature for decisive tool-use agents.- Confirm the exact supported fields against the live model schema via
runware-run. Never guess.
Quality bar
- The loop is bounded (iteration cap with a clear error), not open-ended.
- Every assistant tool-call message and its matching
toolreply are both in history, withtool_call_ids paired correctly. argumentsis parsed (and ideally validated) before the function runs. Tool failures return{ "error": ... }, not exceptions.- Tools are tightly scoped: clear names,
enum/requiredon arguments, compact JSON results. - The model is
liveand supportsio:text-to-text(verified against its card, not assumed).
Related skills
runware-run, runware-models, runware-prompting; vision-understanding (image/video understanding with the same LLMs over the same endpoint).
Related skills
Pick the right Runware model for a task and keep that choice current. Use when an agent needs to decide "which model for X", discover what's available, or ch...
Route messages to any OpenAI-compatible AI agent and keep multi-turn sessions alive across calls.
Allows the AI agent to independently register, login, and authenticate using Firebase.
Get your AI agent productive in 5 minutes. Automated environment scan, smart skill recommendations, and exact install commands. No more trial and error.
Write effective prompts for Runware's image and video models. Use whenever an agent is composing a prompt and wants model-appropriate phrasing, in-image text...