Modal

Modal is a serverless platform for running Python code, AI models, and batch jobs on cloud CPUs and GPUs.

With the Modal block, you can:

  • Call your functions: Send an HTTPS request to a deployed Modal Web Function or Server and get back its response
  • Generate completions: Get chat completions from a model you serve on a Modal Endpoint
  • List models: See which models a token can reach

To connect, create a proxy auth token in your Modal workspace settings and enter its token ID and secret in the block.

In Sim, the Modal block lets your agents use compute you already run on Modal: call a custom inference function, run a GPU job on data from an earlier block, or use your own hosted model inside a workflow.

Usage Instructions

Integrate Modal into your workflow to reach the serverless compute you already run there. Invoke a deployed Web Function or Server over HTTPS with proxy-token auth, generate completions from a model served by a Modal Endpoint, and list the models a token can reach.

Actions

Invoke a deployed Modal Web Function or Server over HTTPS

Input

ParameterTypeRequiredDescription
urlstringYesPublic URL of the deployed Modal Web Function or Server (e.g., https://your-workspace--your-app-your-function.modal.run)
methodstringNoHTTP method to use: GET, POST, PUT, PATCH, DELETE, or HEAD
bodyjsonNoJSON request body sent to the function
queryParamsjsonNoQuery parameters to append to the URL as key-value pairs
headersjsonNoAdditional request headers as key-value pairs
tokenIdstringNoModal proxy token ID (wk-...), required for authenticated functions
tokenSecretstringNoModal proxy token secret (ws-...), required for authenticated functions

Output

ParameterTypeDescription
datajsonBody returned by the function — parsed JSON when it responds with application/json, otherwise the raw text
statusnumberHTTP status code of the response
headersjsonResponse headers as key-value pairs

Generate a chat completion from a model served by a Modal Endpoint

Input

ParameterTypeRequiredDescription
endpointUrlstringNoEndpoint URL from the Modal dashboard or modal endpoint list. Defaults to https://inference.us-west.modal.direct, which routes to Shared Endpoints on the model ID
modelstringYesModel to generate with — the base model repo ID for a dedicated endpoint, or the endpoint hostname for a Shared Endpoint
contentstringYesThe user message content to send to the model
systemPromptstringNoSystem prompt to guide the model behavior
maxTokensnumberNoMaximum number of tokens to generate
temperaturenumberNoSampling temperature (e.g., 0 for deterministic, 0.7 for creative)
topPnumberNoNucleus sampling probability mass between 0 and 1
tokenIdstringYesModal proxy token ID (wk-...)
tokenSecretstringYesModal proxy token secret (ws-...)

Output

ParameterTypeDescription
contentstringGenerated text content
modelstringModel that produced the completion
finishReasonstringWhy generation stopped (e.g., stop, length)
usageobjectToken usage reported by the endpoint
↳ prompt_tokensnumberNumber of tokens in the prompt
↳ completion_tokensnumberNumber of tokens in the completion
↳ total_tokensnumberTotal number of tokens used

List the model IDs a Modal proxy token can reach on an endpoint

Input

ParameterTypeRequiredDescription
endpointUrlstringNoEndpoint URL to query. Defaults to https://inference.us-west.modal.direct, which lists every Shared Endpoint the token can reach
tokenIdstringYesModal proxy token ID (wk-...)
tokenSecretstringYesModal proxy token secret (ws-...)

Output

ParameterTypeDescription
modelsarrayModels the token can reach on the endpoint
countnumberNumber of models returned