15 KiB
\CodeAPI
All URIs are relative to https://api.hanzo.ai
| Method | HTTP request | Description |
|---|---|---|
| GetCodeAsk | Get /v1/code/ask | 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. |
| GetCodeFile | Get /v1/code/file | Returns the INDEXED content of one file — read_file over the chunks the search tiers hold, for pulling up code an agent just found. |
| GetCodeSearch | Get /v1/code/search | Finds code in the caller org's index across three orthogonal retrieval tiers fused by reciprocal-rank fusion: lexical (FTS5 trigram over code-tokenized text), symbolic (real definition and reference edges), and semantic (embedding cosine over AST-boundary chunks). |
| GetCodeTree | Get /v1/code/tree | Returns one repository's file structure with a per-file symbol count — get_repo_structure over the org's own index, with no git checkout involved. |
| PostCodeAsk | Post /v1/code/ask | Answers a question about the caller org's code with a CITED answer, taking the question from the request BODY, for a question too long or too awkward to put in a URL. |
| PostCodeContext | Post /v1/code/context | Packs the most relevant code for a query into a token budget — THE primitive for a coding agent that has to decide what to put in a prompt. |
| PostCodeIndex | Post /v1/code/index | (re)indexes a repository for the caller's org, incrementally: files whose content hash is unchanged are skipped, so re-sending a whole tree is cheap. |
GetCodeAsk
CodeAskAnswer GetCodeAsk(ctx).Q(q).Repo(repo).Execute()
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.
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/hanzoai/go-sdk/v8"
)
func main() {
q := "where is the per-org SQLite file opened" // string | Q is the question to answer. Required, max 4000 bytes. (optional)
repo := "cloud" // string | Repo narrows retrieval to one repository. Empty searches every repo the org has indexed. (optional)
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.CodeAPI.GetCodeAsk(context.Background()).Q(q).Repo(repo).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CodeAPI.GetCodeAsk``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetCodeAsk`: CodeAskAnswer
fmt.Fprintf(os.Stdout, "Response from `CodeAPI.GetCodeAsk`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiGetCodeAskRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| q | string | Q is the question to answer. Required, max 4000 bytes. | |
| repo | string | Repo narrows retrieval to one repository. Empty searches every repo the org has indexed. |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
GetCodeFile
CodeFileContent GetCodeFile(ctx).Path(path).Repo(repo).Execute()
Returns the INDEXED content of one file — read_file over the chunks the search tiers hold, for pulling up code an agent just found.
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/hanzoai/go-sdk/v8"
)
func main() {
path := "apps/code/store.go" // string | Path is the file's repo-relative path. Required. (optional)
repo := "cloud" // string | Repo is the repository the file belongs to. REQUIRED. (optional)
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.CodeAPI.GetCodeFile(context.Background()).Path(path).Repo(repo).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CodeAPI.GetCodeFile``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetCodeFile`: CodeFileContent
fmt.Fprintf(os.Stdout, "Response from `CodeAPI.GetCodeFile`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiGetCodeFileRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| path | string | Path is the file's repo-relative path. Required. | |
| repo | string | Repo is the repository the file belongs to. REQUIRED. |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
GetCodeSearch
CodeSearchResults GetCodeSearch(ctx).Q(q).Type_(type_).Repo(repo).Limit(limit).Execute()
Finds code in the caller org's index across three orthogonal retrieval tiers fused by reciprocal-rank fusion: lexical (FTS5 trigram over code-tokenized text), symbolic (real definition and reference edges), and semantic (embedding cosine over AST-boundary chunks).
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/hanzoai/go-sdk/v8"
)
func main() {
q := "func openStore" // string | Q is the search query. Required, max 4000 bytes. For type=regex it is a regular expression; for type=symbol it is a symbol name. (optional)
type_ := "hybrid" // string | Type selects the retrieval tier: \"text\" (FTS5 trigram), \"regex\", \"symbol\" (definitions), \"semantic\" (embeddings) or \"hybrid\". Anything else — including empty — reads as hybrid. (optional)
repo := "cloud" // string | Repo narrows to one repository. Empty searches every repo the org has indexed. (optional)
limit := int64(20) // int64 | Limit caps how many spans come back: default 20, maximum 100. A value that is not a positive integer reads as the default. (optional)
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.CodeAPI.GetCodeSearch(context.Background()).Q(q).Type_(type_).Repo(repo).Limit(limit).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CodeAPI.GetCodeSearch``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetCodeSearch`: CodeSearchResults
fmt.Fprintf(os.Stdout, "Response from `CodeAPI.GetCodeSearch`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiGetCodeSearchRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| q | string | Q is the search query. Required, max 4000 bytes. For type=regex it is a regular expression; for type=symbol it is a symbol name. | |
| type_ | string | Type selects the retrieval tier: "text" (FTS5 trigram), "regex", "symbol" (definitions), "semantic" (embeddings) or "hybrid". Anything else — including empty — reads as hybrid. | |
| repo | string | Repo narrows to one repository. Empty searches every repo the org has indexed. | |
| limit | int64 | Limit caps how many spans come back: default 20, maximum 100. A value that is not a positive integer reads as the default. |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
GetCodeTree
CodeRepoTree GetCodeTree(ctx).Repo(repo).Execute()
Returns one repository's file structure with a per-file symbol count — get_repo_structure over the org's own index, with no git checkout involved.
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/hanzoai/go-sdk/v8"
)
func main() {
repo := "cloud" // string | Repo is the repository to walk. REQUIRED — a tree is repo-scoped. (optional)
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.CodeAPI.GetCodeTree(context.Background()).Repo(repo).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CodeAPI.GetCodeTree``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetCodeTree`: CodeRepoTree
fmt.Fprintf(os.Stdout, "Response from `CodeAPI.GetCodeTree`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiGetCodeTreeRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| repo | string | Repo is the repository to walk. REQUIRED — a tree is repo-scoped. |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
PostCodeAsk
CodeAskAnswer PostCodeAsk(ctx).CodeAskPostIn(codeAskPostIn).Execute()
Answers a question about the caller org's code with a CITED answer, taking the question from the request BODY, for a question too long or too awkward to put in a URL.
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/hanzoai/go-sdk/v8"
)
func main() {
codeAskPostIn := *openapiclient.NewCodeAskPostIn() // CodeAskPostIn |
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.CodeAPI.PostCodeAsk(context.Background()).CodeAskPostIn(codeAskPostIn).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CodeAPI.PostCodeAsk``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `PostCodeAsk`: CodeAskAnswer
fmt.Fprintf(os.Stdout, "Response from `CodeAPI.PostCodeAsk`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiPostCodeAskRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| codeAskPostIn | CodeAskPostIn |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: application/json, application/problem+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
PostCodeContext
CodeContextBundle PostCodeContext(ctx).CodeContextIn(codeContextIn).Execute()
Packs the most relevant code for a query into a token budget — THE primitive for a coding agent that has to decide what to put in a prompt.
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/hanzoai/go-sdk/v8"
)
func main() {
codeContextIn := *openapiclient.NewCodeContextIn() // CodeContextIn |
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.CodeAPI.PostCodeContext(context.Background()).CodeContextIn(codeContextIn).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CodeAPI.PostCodeContext``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `PostCodeContext`: CodeContextBundle
fmt.Fprintf(os.Stdout, "Response from `CodeAPI.PostCodeContext`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiPostCodeContextRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| codeContextIn | CodeContextIn |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: application/json, application/problem+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
PostCodeIndex
CodeIndexResult PostCodeIndex(ctx).CodeIndexIn(codeIndexIn).Execute()
(re)indexes a repository for the caller's org, incrementally: files whose content hash is unchanged are skipped, so re-sending a whole tree is cheap.
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/hanzoai/go-sdk/v8"
)
func main() {
codeIndexIn := *openapiclient.NewCodeIndexIn() // CodeIndexIn |
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.CodeAPI.PostCodeIndex(context.Background()).CodeIndexIn(codeIndexIn).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CodeAPI.PostCodeIndex``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `PostCodeIndex`: CodeIndexResult
fmt.Fprintf(os.Stdout, "Response from `CodeAPI.PostCodeIndex`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiPostCodeIndexRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| codeIndexIn | CodeIndexIn |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: application/json, application/problem+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]