Answers a question about the caller org's code with a CITED answer: retrieval…
Answers a question about the caller org's code with a CITED answer: retrieval packs grounding context, then the synthesizer writes the answer over exactly…
GET /v1/code/ask
| Address | https://api.hanzo.ai/v1/code/ask |
| Method | GET |
| Operation | get_code_ask |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Answers a question about the caller org's code with a CITED answer: retrieval packs grounding context, then the synthesizer writes the answer over exactly those spans, which come back alongside it. It never answers without grounding — with no matched code the answer is empty and says so, and with no synthesizer available the citations still come back with "degraded": true so the caller can reason over the spans itself.
Request
2 fields.
| Field | In | Type | Required | Description |
|---|---|---|---|---|
q | query | string | — | Q is the question to answer. |
repo | query | string | — | Repo narrows retrieval to one repository. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | AskAnswer | ok |
200 body — 9 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
answer | body | string | — | Answer is the synthesized prose. EMPTY is a real answer here: nothing in the index matched, or synthesis was unavailable — read degraded and citations to… |
citations | body | Citation[] | — | Citations are the exact regions the answer was grounded on, and they are the point: an answer is checkable only because every claim in it can be read back at a… |
citations[].endLine | body | integer | — | EndLine is its last line, inclusive. |
citations[].file | body | string | — | File is the path inside the repo, relative to its root. |
citations[].line | body | integer | — | Line is the first line of the cited region, 1-based. |
citations[].repo | body | string | — | Repo is the repository the cited code lives in ("owner/name"), absent when the ask was already scoped to one. |
citations[].symbol | body | string | — | Symbol is the declaration the region belongs to, when it belongs to one. |
degraded | body | boolean | — | Degraded is true when retrieval worked but no synthesizer was reachable. |
question | body | string | — | Question is the ask, echoed back. |
Failure carries the platform error shape — see Errors.
Examples
hanzo code ask getimport { Configuration, CodeApi } from 'hanzoai';
const api = new CodeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getCodeAsk();from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import CodeApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = CodeApi(client).get_code_ask()cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.CodeAPI.GetCodeAsk(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, code_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = code_api::get_code_ask(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CodeApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new CodeApi(client).getCodeAsk();curl https://api.hanzo.ai/v1/code/ask \
-H "Authorization: Bearer $HANZO_API_KEY"Tool code, op get_code_ask — POST the JSON-RPC envelope to https://api.hanzo.ai/v1/mcp.
curl -X POST https://api.hanzo.ai/v1/mcp \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "code",
"arguments": {
"op": "get_code_ask",
"input": {}
}
}
}'How is this guide?