This port allows you to use Raycast features out of Raycast.
There is no view for this port. You need access then through deeplinks.
More features will be added in the future.
askPrompt
Type: string
Default: undefined
The prompt text.
askOptions
Type: AI.AskOptions
Default: undefined
Options of AI.ask
function.
callbackOpen
Type: Parameters<typeof open>
Default: undefined
Callback with URL or path after the AI.ask
. It will replace RAYCAST_PORT_AI_ANSWER
with the answer.
Exmaple: https://localhost?answer=RAYCAST_PORT_AI_ANSWER
callbackExec
Type: Parameters<typeof exeSync>
Default: undefined
Callback with execSync
after the AI.ask
. The answer will be set to the environment variable RAYCAST_PORT_AI_ANSWER
.
This feature is disabled by default. You need to enable it from extension preferences.
callbackLaunchOptions
Type: LaunchOptions
Default: undefined
Callback with callbackLaunchCommand. All parameters follows the Raycast Cross-Extension Conventions. The answer will be set to callback launch context.
import { execSync } from "node:child_process";
const launchContext = {
askPrompt: "Hello, what's your name?",
askOptions: {
creativity: "high",
model: "openai-gpt-4o",
},
// Callback open URL or file path
callbackOpen: ["https://www.raycast.com/?answer=RAYCAST_PORT_AI_ANSWER", "com.google.Chrome"],
// Callback execute shell command
callbackExec: ['echo "$RAYCAST_PORT_AI_ANSWER" > ~/answer.txt', { shell: true }],
// Callback launch Raycast command
callbackLaunchOptions: {
name: "target-command-name",
type: "userInitated",
extensionName: "target-extension-name",
ownerOrAuthorName: "target-extension-author-name",
context: {
foo: "foo",
bar: "bar",
},
},
};
const context = encodeURIComponent(JSON.stringify(launchContext));
execSync(`open raycast://extensions/litomore/raycast-port/ai-ask?launchType=background&context=${context}`);
deeplink="raycast://extensions/litomore/raycast-port/ai-ask?launchType=background&context=$(jq -rR @uri <<< '{"askPrompt": "hello", "callbackOpen": ["https://example.com/?answer=RAYCAST_PORT_AI_ANSWER"]}')"
open $deeplink
encodeURIComponent
instead of URLSearchParams
due to the parsing issue of Raycast deeplinks.launchType=background
to your deeplink for a better experience.AI.Model['OpenAI_GPT4']
, you might need to look into delcaration file to find out is real value. For JavaScript users, you can simply import the @raycast/api
to use them.MIT