Optionalprojects: ProjectsApiProtectedclientProtectedeip712Hosted REST chat completion (POST /v1/chat/completions). The API
executes any eligible hosted tools server-side and returns the
final result within the request lifetime.
ProtectedlistenersOptionalcompleted?: (data: ChatCompletionResult) => void[]Emitted when a chat completion finishes
Optionalerror?: (Emitted when a chat completion fails
OptionaljobState?: (data: ChatJobStateEvent) => void[]Emitted when the job state changes (queued, assigned to worker, started, etc.)
OptionalmodelsUpdated?: (data: Record) => void[]Emitted when the available LLM models list is updated from the network
Optionaltoken?: (data: ChatCompletionChunk) => void[]Emitted for each token chunk received during streaming
Durable hosted chat runs (POST /v1/chat/runs). A run is submitted
and persisted server-side; the executor drives the LLM/tool loop
without requiring the client to stay connected. Clients can
disconnect and reattach via SSE Last-Event-ID replay or fetch
the final snapshot.
create returns the persisted run record immediately (202).get reads the current run state.cancel flips the run to cancelled and aborts in-flight work.streamEvents yields ChatRunEvents via SSE.Resume a run that paused with run_awaiting_cost_confirmation.
Pass the user's decision (confirm or cancel) and optional
override args. The cloud either dispatches the paused tool
(confirm) or short-circuits with a cancelled tool result.
Tool execution API for Sogni platform tools (image, video, music generation).
Available LLM models and their worker counts
ProtectedattributionOptionaloverride: WorkloadAttributionInputOptionalfallbackOperationId: stringProtectedemitDispatch an event to all listeners
Estimate the cost of a chat completion request before submitting it.
Uses the same token estimation formula as the server: input tokens ≈ ceil(JSON.stringify(messages).length / 4)
Remove an event listener
Add an event listener, returns a function that can be called to remove the listener
Add an event listener that will be called only once
Remove all event listeners, optionally for a specific event
Optionalevent: TProtectedresolveOptionaloverride: WorkloadAttributionInputOptionalfallbackOperationId: stringWait for available LLM models to be received from the network. Resolves immediately if models are already available.
timeout in milliseconds until the promise is rejected (default: 10000)
Chat API for LLM text generation via the Sogni Supernet.
Provides OpenAI-compatible chat completion interface using Sogni's decentralized LLM worker network.
Usage: