POST /buildIntentNaturalLanguage
Last updated
Last updated
This endpoint processes a natural language intent and returns a text response. If a valid intent is detected, it also returns the corresponding input_positions and target_weights required to quote and execute the intent.
This API simplifies the process of converting natural language trade goals into executable intents, which can be traded using Haiku Intents. It enables developers to build seamless workflows, from understanding a user's intent to executing the final transaction.
Developers and traders can use this API to:
Convert natural language into intent: Transform complex user instructions (e.g. "I want to lend all my stablecoins") into structured, executable intents.
intent
string
The user's natural language intent (e.g. "I want to lend all my stablecoins")
wallet_positions
object
prices
object
This endpoint returns a JSON object generated by processing the given intent.
input_positions_str
object
A human-readable string representing the input positions.
target_weights_str
object
A human-readable string representing the target positions.
input_positions
object
target_weights
object
response
string
Textual explanation of the action taken by the model based on the intent
Below is the recommended flow for users processing natural language intents using Haiku's API suite.
Submit the natural language prompt: Send the user's prompt (e.g. "I want to lend my stablecoins
") along with the wallet positions and prices to the POST /buildIntentNaturalLanguage
endpoint.
Handle the model response:
if a valid intent is generated (i.e. the response contains input_positions
and target_weights
), proceed to the next step.
if no intent is generated, prompt the user for more context and re-submit the request.
[Optional] Fine-tune the intent: Edit the generated input_positions
and target_weights
if adjustments are required.
[Optional] Quote the intent: Send the intent to POST /v1/quoteIntent
to receive a human-readable quote (tokens, fees, expected outcomes).
Leverage pre-formatted data: Use wallet positions and prices retrieved from the API to provide structured input for intent creation.
Validate through quoting: Pass the generated positions and weights to the API to preview the trade, including fees and expected outcomes.
Execute intents seamlessly: Finalise the transaction using the API to generate an unsigned EVM transaction ready for signing and broadcasting.
Base URL:
A JSON object of wallet token positions - can be retrieved from
A JSON object of token prices corresponding to the wallet positions - can be retrieved from
Structured input positions for quoting the intent - for use in
Structured target weights for quoting the intent - for use in
Fetch wallet positions: Use the endpoint to retrieve the user's formatted balances and prices.
Submit for trade execution: Pass the generated input_positions and target_weights to the endpoint to generate an unsigned EVM transaction, ready for signing and broadcasting on chain.