Modal

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

On this page