Skip to main content
POST
https://api.mor.org
/
api
/
v1
/
session
/
modelsession
Create Model Session
curl --request POST \
  --url https://api.mor.org/api/v1/session/modelsession \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "sessionDuration": 123,
  "directPayment": true,
  "failover": true
}
'
{
  "session_id": "<string>",
  "provider": "<string>",
  "model_id": "<string>",
  "bid_id": "<string>",
  "duration": 123,
  "cost": "<string>"
}
Create a session with a provider using a model ID and associate it with the API key. This endpoint creates a session and automatically associates it with the API key used for authentication. Each API key can have at most one active session at a time. The system will automatically select the best available bid for the specified model.

Headers

Authorization
string
required
API key in format: Bearer sk-xxxxxx

Query Parameters

model_id
string
required
The blockchain ID (hex) of the model to create a session for, e.g., 0x1234...

Body

sessionDuration
integer
default:3600
Duration of the session in seconds
directPayment
boolean
default:false
Whether to use direct payment instead of allowance
failover
boolean
default:false
Whether to enable automatic failover to another provider

Response

session_id
string
Unique identifier for the created session
provider
string
Provider address
model_id
string
Model identifier used
bid_id
string
Bid identifier that was selected
duration
integer
Session duration in seconds
cost
string
Total cost for the session
Automatic Bid Selection: When creating a session by model ID, the gateway automatically selects the best available bid based on price, provider rating, and availability. Use /api/v1/models/ratedbids?model_id=... to see all available bids first.
Before creating a session, ensure you have approved sufficient MOR tokens using the /api/v1/session/approve endpoint.
Enable failover: true for production applications to automatically switch to another provider if the primary provider becomes unavailable.