{"openapi":"3.0.0","info":{"description":"Modular Cloud inference API — OpenAI-compatible chat completions (text, image, and video input) plus image and video generation via the responses API on api.modular.com; static Bearer key.","version":"v1"},"servers":[{"description":"Modular Cloud inference API — OpenAI-compatible chat completions (text, image, and video input) plus image and video generation via the responses API on api.modular.com; static Bearer key.","url":"https://api.apirails.com/modular"}],"paths":{"/v1/chat/completions":{"post":{"tags":["Chat"],"parameters":[],"responses":{"401":{"description":"Bearer token required (Authorization header)","content":{"application/json":{}}}},"externalDocs":{"api_ref":"https://docs.modular.com/api/inference/create-chat-completion","api_endpoint":"https://api.modular.com/v1/chat/completions"},"summary":"Create chat completion","description":"Generate a response from a conversation. Supports text, image, and video inputs, function calling, and chain-of-thought reasoning (model-dependent). OpenAI-compatible.","security":[{"bearerAuth":[]}],"requestBody":{"description":"","required":true,"content":{"application/json":{"schema":{"type":"object","required":[],"properties":{"frequency_penalty":{"type":"number","description":"Adjusts likelihood of tokens based on their frequency in the output so far (-2 to 2)"},"max_tokens":{"type":"number","description":"Maximum number of tokens to generate"},"messages":{"type":"array","description":"The conversation history. Each message has a role and content. Supported roles depend on the model's chat template: system (instructions), developer (newer alias for system), user, assistant, tool (function results via tool_call_id).","required":true,"items":{"type":"object","properties":{"content":{"type":"string","description":"Plain text content, or a JSON-encoded result string for tool results. For multimodal input send an ARRAY of content parts: {\"type\":\"text\",\"text\":\"...\"}, {\"type\":\"image_url\",\"image_url\":{\"url\":\"https://... or data:<mime>;base64,...\"}}, or {\"type\":\"video_url\",\"video_url\":{\"url\":\"https://...\"}}.","required":true},"role":{"type":"string","description":"Source and purpose of the message","required":true,"enum":["system","developer","user","assistant","tool"]}}}},"model":{"type":"string","description":"Model identifier. See the supported models page (e.g., minimax/minimax-m3, z-ai/glm-5.2, moonshotai/kimi-k2.7-code)","required":true},"presence_penalty":{"type":"number","description":"Adjusts likelihood of tokens based on whether they've already appeared (-2 to 2)"},"reasoning":{"type":"object","description":"Controls chain-of-thought reasoning before responding. An equivalent \"thinking\" parameter is also supported. See the supported models page for reasoning-capable models.","properties":{"effort":{"type":"string","description":"How much reasoning to perform; setting effort implicitly enables reasoning","enum":["low","medium","high"]},"enabled":{"type":"boolean","description":"Whether to enable chain-of-thought reasoning (default depends on the model)","enum":[true,false]}}},"reasoning_effort":{"type":"string","description":"Shorthand for reasoning.effort; if both are set, reasoning.effort takes precedence","enum":["low","medium","high"]},"seed":{"type":"number","description":"Seed for deterministic sampling (determinism isn't guaranteed)"},"stop":{"type":"array","description":"Up to 4 stop sequences that signal the model to stop generating (a single string is also accepted)","items":{"type":"string"}},"stream":{"type":"boolean","description":"If true, stream partial tokens as server-sent events. Tool support while streaming is model-dependent.","enum":[true,false]},"temperature":{"type":"number","description":"Sampling temperature (0-2). Higher values produce more varied output."},"tool_choice":{"type":"string","description":"Controls tool calls: \"none\" disables, \"auto\" (default) lets the model decide, \"required\" forces at least one tool. A function object {\"type\":\"function\",\"function\":{\"name\":\"...\"}} forces a specific function.","enum":["none","auto","required"]},"tools":{"type":"array","description":"Functions the model may call. See the supported models page for models that support tool use.","items":{"type":"object","properties":{"type":{"type":"string","description":"Currently always function","required":true,"enum":["function"]},"function":{"type":"object","description":"Definition of a callable function","required":true}}}},"top_p":{"type":"number","description":"Nucleus sampling threshold (0-1)"}}},"example":{"frequency_penalty":"","max_tokens":512,"messages":[{"content":"What is the capital of France?","role":"user"}],"model":"minimax/minimax-m3","presence_penalty":"","reasoning":{"effort":"medium","enabled":true},"reasoning_effort":"medium","seed":42,"stop":["\n\nUser:"],"stream":"","temperature":0.7,"tool_choice":"auto","tools":[{"type":"function","function":{"description":"Get the current weather for a location","name":"get_weather","parameters":{"type":"object","properties":{"location":{"type":"string"}},"required":["location"]}}}],"top_p":1}}}}}},"/v1/responses":{"post":{"tags":["Images And Video"],"parameters":[],"responses":{"401":{"description":"Bearer token required (Authorization header)","content":{"application/json":{}}}},"externalDocs":{"api_ref":"https://docs.modular.com/api/inference/create-response","api_endpoint":"https://api.modular.com/v1/responses"},"summary":"Create response","description":"Generate an image or video from a text prompt, or transform an input image (image-to-image / image-to-video) via the responses API.","security":[{"bearerAuth":[]}],"requestBody":{"description":"","required":true,"content":{"application/json":{"schema":{"type":"object","required":[],"properties":{"input":{"type":"string","description":"Model input. Send a plain string as the text prompt for text-to-image or text-to-video, OR a structured array with a single user message whose content blocks are {\"type\":\"input_image\",\"image_url\":\"https://... or data:<mime>;base64,...\"} followed by {\"type\":\"input_text\",\"text\":\"...\"} for image-conditioned (image-to-image / image-to-video) generation.","required":true},"model":{"type":"string","description":"Model identifier. See the supported models page (e.g., black-forest-labs/FLUX.2-klein-4B for images)","required":true},"provider_options":{"type":"object","description":"Model-provider-specific generation options (image options)","properties":{"image":{"type":"object","description":"Image generation options"}}},"seed":{"type":"number","description":"Random seed for reproducible outputs"}}},"example":{"input":"A watercolor painting of a lighthouse at dusk","model":"black-forest-labs/FLUX.2-klein-4B","provider_options":{"image":{"height":1024,"width":1024}},"seed":42}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"security":[{"bearerAuth":[]}]}