Skip to content
AnnouncementSomnia Oracle settles event contracts onchain, in minutes, with receipts.

Deterministic AI your contracts can settle on.

Somnia LLM Inference runs large language models inside Somnia. Every validator in a subcommittee runs the same pinned model on the same input and must return a byte-identical answer, so the contract gets an answer the validators agreed on.

Read the docs
Request 51870inferString4 of 4 identicalIllustrative

Input

system
You are a market moderator. Answer accept or reject.
prompt
Is this question clear and resolvable? "Will the venue publish its 2026 annual report by 31 March 2027?"
allowedValues
["accept", "reject"]
chainOfThought
false

Pinned on every validator

model
open-weight
seed
fixed
temperature
0

Same input, four validators

ValidatorModelSeedTempOutputOutput hashMatch
0x8f3a…21c4pinnedfixed0accept0x9c1e…44abIdentical
0x2b91…7e05pinnedfixed0accept0x9c1e…44abIdentical
0xc604…9a38pinnedfixed0accept0x9c1e…44abIdentical
0x47de…b610pinnedfixed0accept0x9c1e…44abIdentical
ConsensusByte-identical output from 4 of 4 validatorsto callbackhandleResponse("accept")
Receipts
4 signed, one per validator, available for audit
Deposit
Unspent deposit refunded with the callback
Output modes: text from a set list, bounded numbers, chat and tool calls
4
Output modes: text from a set list, bounded numbers, chat and tool calls
Somnia docs, LLM Inference
Validators per request, set by the calling contract
Up to 10
Validators per request, set by the calling contract
Somnia docs, Gas fees
Temperature on every validator, with a fixed seed
0
Temperature on every validator, with a fixed seed
Somnia docs, LLM Inference
Priced per request in SOMI; see the docs for current prices
Priced per request in SOMI; see the docs for current prices

An answer every validator can repeat.

Every validator gets the same output from the same input. That is how a subcommittee agrees on one answer, and why a contract can act on it.

  • Get the same answer from every validator

    Fixed seeds, zero temperature and a pinned open-weight model make inference deterministic, so independent validators reproduce the exact same output.

  • Get one answer agreed by validators

    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

    Each validator signs a receipt of the steps it took, with optional chain-of-thought, so you can audit how an answer was reached.

  • Call the model like any other function

    Contracts call the model and get the result in a callback, with no API keys and no offchain service to run.

Where the answer comes fromFrom the live page
QuestionSingle endpointSomnia
Who runs itOne providerA validator subcommittee
Same inputOutput can varyByte-identical output
Switched offBy the providerNot by any one party
Audit trailProvider logsSigned receipts
To call itAPI key and a serverA function call
ReasoningUp to the providerOptional, in receipts
Answer goes toYour serverThe contract callback

Choose the answer your logic needs.

Every method goes through the same agent, with the same pinned model and the same consensus.

  • inferString

    Call inferString for single-turn text, optionally limited to a list of allowed values.

    IN · allowedValues
    ["safe", "unsafe"]
    OUT · response
    "safe"
  • inferNumber

    Call inferNumber to get an integer answer clamped to the range you set.

    IN · minValue, maxValue
    1 to 10
    OUT · response
    7
  • inferChat

    Call inferChat for multi-turn conversations with system, user and assistant roles.

    IN · messages
    system, user, assistant
    OUT · response
    response: string
  • inferToolsChat

    Call inferToolsChat for tool use with MCP servers, or with onchain functions that come back to your contract as calldata.

    IN · tools
    mcpServerUrls, onchainTools
    OUT · finishReason
    "stop", "tool_calls" or "max_iterations"

Put judgement into contract logic.

Create, moderate and resolve markets

Prophecy uses Somnia LLM Inference to moderate and name every new market, and Somnia Oracle uses the same deterministic stack to weigh evidence into a verdict.

  • Moderation limited to accept or reject
  • Market naming at creation
  • Evidence weighed into a single verdict
Somnia Oracle
New marketIllustrative
Question
"Will the venue publish its 2026 annual report by 31 March 2027?"
Moderation
inferString, allowedValues accept or reject
Result
accept, 4 of 4 identical
Name
Venue annual report, March 2027
Resolution
Somnia Oracle weighs the evidence
Verdict
One answer, with signed receipts

Send a prompt, get one agreed answer.

moderate.tstypescript
// 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: 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
]
});
Returnsresponse"safe"Agreed by the subcommittee

From the LLM Inference docs. The calldata is sent through the Somnia Agents platform like any agent request; the return is illustrative.

Give the model tools, run its onchain calls.

inferToolsChat lets the model use MCP tools and propose onchain calls, which your contract runs itself.

Run MCP tools automatically

Pass MCP server URLs. The agent discovers the tools, calls them, feeds each result back to the model and continues until it is done.

  1. Discover tools from each MCP server
  2. Model calls a tool, the agent runs it
  3. Result fed back to the model
  4. finishReason "stop", response returned
MCP tool use

Run each onchain tool call from your own contract

Describe functions by Solidity signature. The model's calls come back to your contract as ABI-encoded calldata to execute before resuming.

  1. Tool defined by signature and description
  2. finishReason "tool_calls", calldata returned
  3. Your contract executes each call
  4. Resume with the results, up to maxIterations
Onchain tool use

Set the limits on every answer.

  • Limit answers to values you allow

    inferString takes a list of allowed values, or none for free text.

  • Keep numbers inside your range

    inferNumber clamps the answer to the minimum and maximum you set.

  • See how the model reasoned

    Optional reasoning, recorded in the execution receipts.

  • Choose how answers are agreed

    Accept identical answers, or receive every result and aggregate onchain.

  • Audit every validator's steps

    Each validator signs a receipt for its run, so anyone can check it later.

  • Stop tool loops at a set limit

    maxIterations caps model and tool round-trips for each tool-use call.

Give your contract a model to call.

Run an inference in the Agent Explorer, or talk to the team about the judgement your contract needs.

Talk to an expert