Home > Article > Web Front-end > How to Use the AI Experimental API in Chrome
To use the experimental AI API in Chrome, follow these steps:
There is no support yet for:
If it fails, try the following:
Note: Sometimes the model installation may take a while. Be patient and repeat the process if necessary.
To activate the models, enable the following flags in Chrome:
This is the simplest model, used for general tasks. When you send it a prompt, it tries to return a response. Here is a basic example:
const session = await ai.assistant.create(); const result = await session.prompt("Explain what JavaScript is");
You can also use systemPrompt to pass additional instructions:
const session = await ai.assistant.create({ systemPrompt: "You are an expert in JavaScript, providing helpful code best practices." });
This API detects the language of a text, supporting more than 100 languages and variants.
Example:
const detector = await translation.createDetector(); const results = await detector.detect("Bonjour le monde"); for (const result of results) { console.log(result.detectedLanguage, result.confidence); }
Writer API: Create new content.
Example: writing a draft of an application to the bank.
const writer = await ai.writer.create(); const result = await writer.write("Write a email asking for feedback");
Rewriter API: Improves or restructures an existing text.
const rewriter = await ai.rewriter.create(); const result = await rewriter.rewrite("La inteligencia artificial es...", { context: "Use simple words." });
All these APIs are in the experimental phase, so it is normal to find errors or inconsistencies. All feedback is welcome. If you are interested in being aware of the changes, you can fill out this form to access the documentation and receive updates.
The above is the detailed content of How to Use the AI Experimental API in Chrome. For more information, please follow other related articles on the PHP Chinese website!