Somnia LLM Inference
Somnia LLM Inference
Somnia LLM Inference runs large language models inside Somnia, powered by the Somnia Validator Network. Every validator in a subcommittee runs the same pinned model on the same input and must return a byte-identical answer, so the result a contract receives is consensus-validated, verifiable and free of single-party control.
Deterministic AI your contracts can settle on.
Why Somnia LLM Inference
Same prompt, same answer, on every validator
Fixed seeds, zero temperature and a pinned open-weight model make inference deterministic, so independent validators reproduce the exact same output.
Consensus instead of a single provider
A single model endpoint can be manipulated or switched off. Answers on Somnia are agreed by a subcommittee of validators before a contract sees them.
Inspect the reasoning
Every execution produces signed receipts of the steps each validator took, including optional chain-of-thought, so you can audit how an answer was reached.
AI as a primitive, not a dependency
Contracts call the model like any other function and get the result in a callback. No API keys, no offchain service to run and no trusted middleman.
How an inference request runs
- Request. A contract sends a prompt to the Somnia Agents platform with a small deposit and a callback.
- Elect. A subcommittee of validators from the Somnia Validator Network is chosen to run the request.
- Infer. Each validator runs the same pinned model with a fixed seed and zero temperature.
- Agree. Results are compared. Under majority consensus, byte-identical answers from the threshold of validators finalise the request.
- Deliver. The agreed answer is returned to the contract's callback, with signed receipts available for audit and unspent deposit refunded.
Capabilities
- inferString. Single-turn text, optionally constrained to a list of allowed values.
- inferNumber. An integer answer clamped to the range you set.
- inferChat. Multi-turn conversations with system, user and assistant roles.
- inferToolsChat. Tool use with MCP servers and onchain functions returned as calldata.
- Chain-of-thought. Optional reasoning, recorded in the execution receipts.
- Majority or threshold consensus. Accept identical answers, or receive every result and aggregate onchain.
Example
moderation.ts
// From docs.somnia.network/agents/base-agents/llm-inference
const abi = [{
type: 'function',
name: 'inferString',
inputs: [
{ name: 'prompt', type: 'string' },
{ name: 'system', type: 'string' },
{ name: 'chainOfThought', type: 'bool' },
{ name: 'allowedValues', type: 'string[]' }
],
outputs: [{ name: 'response', type: 'string' }]
}];
// Content moderation example — constrain output to "safe" or "unsafe"
const calldata = encodeFunctionData({
abi,
functionName: 'inferString',
args: [
'Analyze the following text: "Check out this amazing new product!"',
'You are a content moderation assistant.',
false, // chainOfThought
['safe', 'unsafe'] // allowedValues
]
});
Further reading
Placeholder generated from the platform site's product copy, until this section is sourced from the product's repo.Edit this page