Skip to main content

Model Endpoints

Every model on FlyMy.AI is addressed by its endpoint id, written as {owner}/{model} - for example flymyai/google-gemini-25-flash. The endpoint id maps directly into the URL path.

https://api.flymy.ai/api/v1/{owner}/{model}/{route}

Authentication

All routes take an API key in the X-API-KEY header:

-H "X-API-KEY: fly-***"

Create keys in your FlyMy.AI account settings. A key can call any public model plus every model you own.

Routes

RoutePurpose
POST /predictRun the model and wait for the complete result
POST /predict/stream/Run the model and receive the result incrementally over SSE
POST /predict/async/Queue the run and return a task id immediately
POST /predict/async/result/Fetch the result of a queued run
POST /predict/cancel/Cancel a running prediction by its prediction_id
GET /openapi.jsonThe model's own schema: exact inputs, types, and output fields

Not every model supports every route. Text generation models are streaming-only and reject /predict; see Using LLMs.

Discovering a model's inputs

Rather than guessing parameter names, read the schema the model publishes:

curl -H "X-API-KEY: fly-***" \
https://api.flymy.ai/api/v1/flymyai/google-gemini-25-flash/openapi.json

The input fields live under components.schemas.DynamicInputModel, and the output fields under DynamicOutputModel. An output field marked "isStream": true means the value is delivered progressively and the model should be called through /predict/stream/.

Request format

Requests are sent as form data, not JSON - this is what allows file inputs such as images and audio to travel in the same request as text parameters.

curl -X POST \
https://api.flymy.ai/api/v1/flymyai/google-gemini-25-flash/predict/stream/ \
-H "X-API-KEY: fly-***" \
-F "prompt=Hello"

A JSON body returns 422 Field required even when the JSON itself is valid.

Response format

Synchronous

/predict returns a single JSON document with the model's outputs under output_data.

Streaming

/predict/stream/ returns a Server-Sent Events stream. The first event acknowledges the request and carries the prediction_id used for cancellation:

event: {"prediction_id":"f9e443caf50e..."}

Content events follow, each carrying a fragment of the output:

data: {"output_data":{"output":["first fragment "]},"status":200}

The stream closes with a final event whose output_data is empty and which carries usage information. For token-priced models this is stream_details with the token counts the charge is computed from:

data: {"output_data":{},"status":200,"stream_details":{"input_tokens":15,"output_tokens":49}}

Disable client-side buffering when consuming a stream, otherwise your HTTP client may hold the fragments and hand you the whole response at the end. With curl, pass -N.

Errors

Transport-level failures use standard HTTP status codes. Some conditions are reported inside a 200 response body with their own status_code field, so check the payload rather than the HTTP status alone:

{"detail":"Predict is not available for current pipeline. Use /predict/stream route instead!","status_code":421}
StatusMeaning
403 API key does not have access to the projectModel is private and you are not its owner
403 Insufficient fundsWallet balance is negative
403 Project is not activeThe project has no capacity allocated
404 Project not foundThe endpoint id does not exist
422 Field requiredA required parameter is missing, or the body was sent as JSON

See Errors for the full list.