React Native Requires Chilkat v11.2.0+
React Native
AI: Set Ask Params
See more AI Examples
Demonstrates how to set the followingAsk parameters: temperature, effort, and max_output_tokens.
Chilkat React Native Downloads
import { Ai, JsonObject, StringBuilder } from '@chilkat/react-native'
async function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const ai = new Ai();
ai.verboseLogging = true;
ai.provider = 'google';
ai.apiKey = 'MY_API_KEY';
ai.model = 'gemini-3.6-flash';
// Note: Not all models support all params.
// Set Ask params.
const askParams = new JsonObject();
askParams.updateNumber('temperature', '1.2');
askParams.updateString('effort', 'low');
askParams.updateInt('max_output_tokens', 1024);
askParams.emitCompact = false;
console.log(askParams.emit());
ai.setAskParams(askParams);
// Add a text input.
ai.inputAddText('Say Hello.');
// Ask the AI for text output.
try {
await ai.askAsync('text');
} catch {
console.log(ai.lastErrorText);
return;
}
// Get the text response.
const sbResponse = new StringBuilder();
ai.getOutputTextSb(sbResponse);
console.log(sbResponse.getAsString());
// Sample output:
// Hello! How can I assist you today?
// -------------------------------------------------------------
// The response is in markdown format.
// Also see Markdown to HTML Conversion Examples.
// -------------------------------------------------------------
}