ask
hc.ask(prompt, options?)
Available since v2.0.0
Signature:(prompt: string, options?: { model?: string }) => Promise<string | null>
| Parameter | Type | Description |
|---|---|---|
prompt | | Required. Text sent to the model. |
options.model | | Optional. Model selection as "name" or "name: source". name is a model label or provider id (for example GPT-4o or gpt-4o). source is a group label: Personal, GitHub Models, or a Team Hub display name. Matching is case-insensitive. |
Sends a one-shot prompt to a configured AI model and returns the model's text response. Use this when a script needs a short LLM answer (summarize a body, classify a status, draft a value) without opening the AI sidebar.
HarborClient automatically includes the current send's request in the model context. In post-request scripts the response is included too (status, headers, sizeBytes, and a truncated text body preview). Binary/image bodies omit base64 and rely on sizeBytes so questions like “what is the image file size?” can be answered without pasting the body into your prompt.
Use await — scripts are evaluated as async functions, so top-level await hc.ask(...) is supported.
When options or options.model is omitted, HarborClient uses the first available model. When only the model name is given (no : source), the first matching model from any source is used.
Returns null when AI is not configured (no personal API keys, GitHub Models, or Team Hub LLM models) or when the selection cannot be resolved. LLM and runtime failures throw.
Configure AI first — see AI assistant — API keys.
var sizeAnswer = await hc.ask("What is the file size of the image?", {
model: "gpt-4o: personal",
});
if (sizeAnswer == null) {
console.log("AI not configured or model not found");
} else {
console.log(sizeAnswer);
}