Skip to main content
Use function tools to let a model request actions in your application. Your application runs the action and sends the result back to the model. You can use this pattern to search, read files, or call Floodgate’s image, speech, and video APIs.

How function calls work

  1. Send tool definitions with your model request using the chosen API’s tool schema.
  2. Read the model’s tool call and its arguments.
  3. Run the function in your application.
  4. Return the function result to the model so it can continue.
Use the tool format for your selected API, such as Chat Completions, Responses, or Messages. Model input and output tokens use the selected group’s normal prices.

Connect an MCP server

Add the MCP server to your coding client’s configuration. The client makes the server’s tools available to the model and handles tool execution. Configure MCP servers in the client you use. See the coding tool guides for Floodgate connection settings.

Add image and speech tools

Create a script, application function, or MCP tool that:
  1. Accepts a prompt or text and the desired model.
  2. Sends a request to the Images API or Speech API.
  3. Saves the returned image or audio and gives the client a file path or result reference.
Store your API key in the tool’s environment. Keep it out of prompts and tool arguments.

Add a video tool

A video tool submits the request, keeps the returned task ID, and checks progress until the video completes. It then downloads the result using the same account’s credentials. Keep task IDs so you can resume checking an existing job after a timeout. See Video generation for request formats and download endpoints.

Use search tools

Connect a search function or MCP server to your client. The client runs the search and returns its results to the model. Search tools can have their own provider fees. Calls from your media tools to Floodgate use your balance and the price of the selected media model.