This repository is the source of truth for Tarka's public API surface. It contains the Protocol Buffer definitions that power Tarka's gRPC control API and the OpenAPI contracts for its HTTP compatibility surfaces.
The API is designed to work like other public schema repositories: clone or pin this repository, then generate a client in any language supported by Protocol Buffers and gRPC. This repository intentionally contains no generated language bindings and no Tarka implementation code.
Externally observable API contracts and the small client skill example below belong here. Service handlers, business rules, authentication and authorization implementation, persistence, controllers, gateway hooks, runtime code, container definitions, and deployment manifests remain in Tarka's private infrastructure repository. Generated bindings used by Tarka are produced inside that private build. CI enforces this boundary and rejects generated language sources, application dependency manifests, service/runtime directories, container definitions, deployment manifests, and repository dependencies.
| Path | Purpose |
|---|---|
proto/tarka/provisioning/v1 |
Authoritative control-plane protobuf and gRPC definitions |
proto/tarka/inference/v1 |
Authoritative inference protobuf and gRPC definitions |
proto/tarka/databases/v1 |
Authoritative record data API of managed databases |
openapi/tarka-control-v1.swagger.json |
Generated OpenAPI v2 description of the control API's REST transcoding surface |
openapi/tarka-inference-v1.openapi.json |
Authored OpenAPI 3.1 contract for the supported OpenAI-compatible inference surface |
openapi/tarka-iam-oauth-v1.openapi.json |
Authored customer OAuth discovery, CIMD, public DCR, authorization and token contracts on the configured environment issuer |
openapi/tarka-billing-v1.openapi.json |
Authored organization billing and card verification HTTP contract |
openapi/tarka-runtime-v1.openapi.json |
Authored HTTP contract for trusted harness runs, verified messaging claims and private replies on the configured gateway origin |
openapi/tarka-inference-v2.openapi.json |
Authored OpenAPI 3.1 contract for the deprecated /v2 REST alias |
openapi/tarka-inference-v1.swagger.json |
Generated OpenAPI v2 description of protobuf-bound inference methods |
contracts/agent-hosts |
Versioned OpenClaw, Hermes, and Onyx Compose contracts plus their machine-readable release catalog |
contracts/databases |
Cases pinning how the PocketBase-compatible HTTP endpoints translate to DatabaseService |
examples/tarka-control-api |
Copyable Claude Code / Codex skill with a dependency-free Control API helper |
buf.yaml |
Buf module, lint, dependency, and compatibility policy |
buf.gen.yaml |
Pinned generator for the derived control OpenAPI document |
Never edit either generated Swagger document by hand; they are derived from
protobuf annotations and CI rejects drift. The authored inference OpenAPI
documents define the exact HTTP wire contracts for /v1 and /v2, including
multipart uploads and byte-stream responses that protobuf transcoding alone
cannot describe precisely.
- The gRPC-first control API manages accounts, organizations, keys, quotas,
usage, object storage, hosted Git, sandboxes, and desired-state resources. Its REST
transcoding routes live under
/control/v1. - The inference API is a deliberately scoped OpenAI-compatible HTTP API at
https://tarka.rest/v1. It supports models, chat completions, OCR, structured document layout, Responses, transcription, translation, speech generation, and consent-backed voice cloning through the endpoints intarka-inference-v1.openapi.json. OCR is available both through the dedicatedPOST /v1/ocrendpoint and through multimodalPOST /v1/chat/completionsrequests. The Tarka extensionPOST /v1/document/layoutreturns ordered regions with confidence scores and geometry while preserving the same authentication, discovery, metering, and error conventions. - The database data API,
tarka.databases.v1.DatabaseService, reads and writes the records of one managed database: records, atomic batches, files, and realtime changes. It is gRPC-first as well. The generated REST routes under/control/v1/orgs/{org_id}/databases/{database_id}and the PocketBase-compatible endpoints of each database are translations of the same RPCs. - Every inference operation also has a native gRPC method at
grpc.tarka.rest:443. The REST gateway calls those same authenticated gRPC methods, so REST and gRPC share authorization, model routing, metering, persistence, and errors. /v2is a deprecated compatibility alias for/v1. It is not a newer API generation and advertises its deprecation in HTTP response headers.
Native clients use tarka.inference.v1.InferenceService, matching the canonical
REST version. Regenerate clients from this contract before switching to the v1
gRPC service; the package rename changes fully qualified RPC and message names.
See VERSIONING.md for the coordinated migration.
The REST endpoint is tarka.rest:443 and the native gRPC endpoint is
grpc.tarka.rest:443, both over TLS. Authentication metadata uses the standard
authorization: Bearer <token> key. Control-plane RPCs use a Tarka account
access token. Customer keys beginning with tk_live_ are accepted by the
Inference API and, when they include the sandboxes scope, by SandboxService
RPCs. A key with the databases scope is accepted by the managed database
RPCs and by DatabaseService.
Inside any tarka.run workload, the same canonical REST API is available at
http://tarka/v1 without a caller-supplied Authorization header. The
workload's service identity is injected only by the namespace-local platform gateway and
is rejected by Tarka's public API surfaces. A host may instead run its chat
model on an OpenAI-compatible endpoint and key the customer brings
(runtime.model_endpoint); the same gateway forwards that model's requests
there and keeps every other model on Tarka.
Every compute workload has that private gateway at http://tarka: Agent
Hosts, HTTP services (Functions), batch jobs, code sandboxes and container
sessions use the same routes for inference, database records, object storage,
Hosted Git, the project's API and MCP gateways, invoking other compute and
project secrets, and the platform authenticates the workload so code holds no
credential. contracts/compute/README.md
defines the routes, the required Tarka-Workload: 1 header (every route but
/v1 needs it), zero-setup databases and the error codes. WorkloadAccess
selects what each workload may reach (CreateComputeWorkloadRequest.access,
GetWorkloadAccess, SetWorkloadAccess).
Only the defaults differ by use case. Agent Hosts, HTTP services and batch jobs
start with inference, their own database and the project's default database
on. Code sandboxes and container sessions start with everything off and have
no database of their own. A workload gets platform access when at least one
capability is on; a capability its access has not enabled answers
403 capability_disabled. In HTTP services and batch jobs the platform sets
TARKA_API_URL=http://tarka/v1 and configures git to send the
Tarka-Workload: 1 header to http://tarka only; in Agent Hosts, code
sandboxes and container sessions, code sets that git header itself.
The control REST gateway is rooted at https://tarka.rest/control/v1. It
accepts Authorization: Bearer <Tarka account access token> and uses protobuf
field names in JSON. A tk_live_ inference key is not an account token and is
rejected by ordinary Control API methods. The deliberate exceptions also accept
a tk_live_ key with the matching scope: sandbox methods, compute quotes and
HTTP service invocation with sandboxes, and database and record methods with
databases.
Requests with unknown JSON fields are rejected. Sandbox mutations accept an
idempotency key either in their request message or through the
Idempotency-Key HTTP/gRPC metadata header.
The Control API is the automation surface behind customer workspace actions in
the Tarka Console. Its contract is gRPC-first; every REST route below is a
transcoding binding on the same protobuf method. JSON field names are
snake_case, timestamps use RFC 3339, and 64-bit integers may be serialized as
JSON strings by protobuf-aware clients.
The API has these credential boundaries:
| Credential | Accepted by | Purpose |
|---|---|---|
| Tarka account access token | Every Control API method | Identity, organizations, credentials, policy, usage, and provisioning |
tk_live_ key with sandboxes scope |
SandboxService methods only | Organization-bound sandbox automation |
tk_live_ key with databases scope |
Managed database methods and DatabaseService | Organization-bound database automation and record access with the key creator's role |
| Project identity token or agent runtime credential | DatabaseService only | Record access as an application user or attached agent, subject to collection rules |
tk_live_ key with himalaya, inference, or utilities scope |
Inference API only | Runtime requests for HimalayaAI, general LLM, or utility model categories |
Account access must be approved, the organization must be active, and the
caller must have an active organization membership. Read operations generally
accept every organization role. Organization metadata, quota and spend-limit changes
require an owner or admin. API-key, compute, storage, and repository mutations require
an owner, admin, or operator. Product entitlements add a second gate for
private-beta model categories, Agent Hosts, Batch Jobs, Sandboxes, Object
Storage, and Hosted Git. A key scope cannot exceed its creator's current product
entitlement, and removing that entitlement blocks existing model keys.
Time-limited grants expose expires_at and stop authorizing requests as soon as
that timestamp passes. The canonical product identifiers, display metadata,
API-key capabilities, and operator presets are versioned in
contracts/product-access.json; generated or
copied policy definitions in implementation repositories must originate there.
| Method | REST route | Ability |
|---|---|---|
GetCurrentUser |
GET /control/v1/me |
Return the account identity, product entitlement decisions, and every active organization membership |
BootstrapCurrentUser |
POST /control/v1/me/bootstrap |
Idempotently create the first organization when none exists |
CreateOrg |
POST /control/v1/orgs |
Create an additional organization and owner membership |
GetOrg |
GET /control/v1/orgs/{org_id} |
Read one visible organization |
UpdateOrg |
PATCH /control/v1/orgs/{org_id} |
Change an organization display name |
ListOrgMembers |
GET /control/v1/orgs/{org_id}/members |
List active and inactive memberships |
RequestProductAccess |
POST /control/v1/orgs/{org_id}/product-access-requests |
Submit a private-beta product request |
ListProductAccessRequests |
GET /control/v1/orgs/{org_id}/product-access-requests |
List recent requests, optionally filtered by product |
Organization selection in the web console is browser state, not a server-side
Control API resource. API callers select an organization by putting org_id in
the route or request message.
| Method | REST route | Ability |
|---|---|---|
ListModels |
GET /control/v1/models |
List active model aliases with their server-owned access_product, optionally filtered by modality |
CreateApiKey |
POST /control/v1/orgs/{org_id}/api-keys |
Create a scoped tk_live_ key; plaintext is returned once |
ListApiKeys |
GET /control/v1/orgs/{org_id}/api-keys |
List redacted key metadata |
RevokeApiKey |
POST /control/v1/orgs/{org_id}/api-keys/{api_key_id}:revoke |
Permanently revoke a key |
GetQuotaPolicy |
GET /control/v1/orgs/{org_id}/quota-policy |
Read effective concurrency, request, token, and model policy |
UpdateQuotaPolicy |
PUT /control/v1/orgs/{org_id}/quota-policy |
Replace the organization quota policy |
GetSpendLimits |
GET /control/v1/orgs/{org_id}/spend-limits |
Read the monthly spend limit, per-product limits, and what each has been charged this UTC calendar month |
UpdateSpendLimits |
PUT /control/v1/orgs/{org_id}/spend-limits |
Replace the monthly spend limits; priced inference past a limit is refused with HTTP 402 and spend_limit_reached |
ListUsageEvents |
GET /control/v1/orgs/{org_id}/usage/events |
Read newest metered requests; limit defaults to 25 and caps at 100 |
GetUsageSummary |
GET /control/v1/orgs/{org_id}/usage/summary |
Aggregate the current UTC calendar month |
ListProvisionedResources |
GET /control/v1/orgs/{org_id}/resources |
List desired-state resources, optionally by resource_type |
GetProvisionedResource |
GET /control/v1/orgs/{org_id}/resources/{resource_id} |
Read one desired-state resource and status detail |
CreateInferenceService |
POST /control/v1/orgs/{org_id}/inference-services |
Apply managed inference desired state |
ListAgentHostTemplates |
GET /control/v1/agent-host-templates |
List versioned OpenClaw, Hermes, Onyx, and future Compose templates |
GetAgentHostGatewayPairing |
GET /control/v1/orgs/{org_id}/agent-hosts/{agent_host_id}/gateways/{gateway_id}/pairing |
Create a short-lived post-deploy gateway pairing artifact without exposing its private runtime |
CreateAgentHost |
POST /control/v1/orgs/{org_id}/agent-hosts |
Apply a template, inline Compose stack, or backward-compatible single image after beta approval |
GetAgentHostConfiguration |
GET /control/v1/orgs/{org_id}/agent-hosts/{agent_host_id}/configuration |
Read the editable active revision with every secret value redacted |
ListAgentHostTerminalTargets |
GET /control/v1/orgs/{org_id}/agent-hosts/{agent_host_id}/terminal-targets |
List running application containers available for interactive shells |
CreateAgentHostTerminal |
POST /control/v1/orgs/{org_id}/agent-hosts/{agent_host_id}/terminals |
Open a bounded, owner-bound PTY session |
ReadAgentHostTerminal |
GET /control/v1/orgs/{org_id}/agent-hosts/{agent_host_id}/terminals/{terminal_id} |
Read output from a byte cursor, optionally waiting up to 20 seconds |
WriteAgentHostTerminal |
POST /control/v1/orgs/{org_id}/agent-hosts/{agent_host_id}/terminals/{terminal_id}:write |
Deliver ordered input bytes or resize the terminal; retries of the last sequence are idempotent |
CloseAgentHostTerminal |
DELETE /control/v1/orgs/{org_id}/agent-hosts/{agent_host_id}/terminals/{terminal_id} |
Disconnect an interactive shell |
DeleteAgentHost |
DELETE /control/v1/orgs/{org_id}/agent-hosts/{agent_host_id} |
Request deletion of an Agent Host stack |
CreateJob |
POST /control/v1/orgs/{org_id}/jobs |
Queue an immutable job revision when its runtime is enabled |
GetJob |
GET /control/v1/orgs/{org_id}/jobs/{job_id} |
Read desired state and the latest run identifier |
ListJobRuns |
GET /control/v1/orgs/{org_id}/jobs/{job_id}/runs |
Page through one job's execution history |
GetJobRun |
GET /control/v1/orgs/{org_id}/jobs/{job_id}/runs/{run_id} |
Read execution status without downloading logs |
CancelJobRun |
POST /control/v1/orgs/{org_id}/jobs/{job_id}/runs/{run_id}:cancel |
Request idempotent cancellation and wait for confirmed termination |
GetJobRunResult |
GET /control/v1/orgs/{org_id}/jobs/{job_id}/runs/{run_id}/result |
Read terminal results and obtain a temporary log download |
CreateInferenceService, CreateAgentHost, and CreateJob are desired-state
apply operations: reusing an organization, resource type, and name creates a
new revision on the same resource identity. Agent Host Compose documents may
reference encrypted variables, but secret values are never returned through
ProvisionedResource.spec or the editable configuration response. Updates can
explicitly preserve an existing encrypted secret without retrieving it. Generic
resource reads do not imply a generic delete operation; DeleteAgentHost is
the explicit Agent Host lifecycle operation.
| Method | REST route | Ability |
|---|---|---|
CreateStorageBucket |
POST /control/v1/orgs/{org_id}/storage/buckets |
Provision a private, versioned bucket |
ListStorageBuckets |
GET /control/v1/orgs/{org_id}/storage/buckets |
List organization buckets |
DeleteStorageBucket |
DELETE /control/v1/orgs/{org_id}/storage/buckets/{bucket_id} |
Delete an empty bucket |
CreateStorageCredential |
POST /control/v1/orgs/{org_id}/storage/buckets/{bucket_id}/credentials |
Create a bucket-bound S3 access key and one-time secret |
ListStorageCredentials |
GET /control/v1/orgs/{org_id}/storage/buckets/{bucket_id}/credentials |
List redacted S3 credential metadata |
RevokeStorageCredential |
POST /control/v1/orgs/{org_id}/storage/buckets/{bucket_id}/credentials/{credential_id}:revoke |
Permanently revoke an S3 credential |
EnsureHostedGitAccess |
POST /control/v1/me/git-access |
Provision or reconcile the account's Hosted Git identity |
CreateGitRepository |
POST /control/v1/orgs/{org_id}/git-repositories |
Create a private, LFS-enabled repository |
ListGitRepositories |
GET /control/v1/orgs/{org_id}/git-repositories |
List repositories and clone URLs |
DeleteGitRepository |
DELETE /control/v1/orgs/{org_id}/git-repositories/{repository_id} |
Delete a repository and retain its final control-plane state |
S3 credentials are separate from Tarka API keys. access_key_id and
secret_access_key are returned together only at credential creation; later
list operations return redacted metadata. Hosted Git data-plane authentication
uses an SSH key or a Forgejo personal access token, not a tk_live_ key.
A managed database belongs to a project. Its collections, access rules,
Function triggers, and schedules come from a release manifest; record data is
read and written through DatabaseService. A compute workload's own database
and a project's default database (owner_workload_id, project_default) are
created on first use and start in implicit schema mode, where a first write
creates a collection or field. Submitting a release or connecting a source
switches a database to managed mode (schema_mode);
contracts/compute has the details.
| Method | REST route | Ability |
|---|---|---|
CreateManagedDatabase |
POST /control/v1/orgs/{org_id}/databases |
Create a database in a project |
ListManagedDatabases |
GET /control/v1/orgs/{org_id}/databases |
List a project's databases, optionally including deleted ones that can be restored |
GetManagedDatabase |
GET /control/v1/orgs/{org_id}/databases/{database_id} |
Read state, settings, and the latest release |
UpdateManagedDatabase |
PATCH /control/v1/orgs/{org_id}/databases/{database_id} |
Rename, toggle backups and public HTTPS, select a gateway, or connect a Git schema |
DeleteManagedDatabase |
DELETE /control/v1/orgs/{org_id}/databases/{database_id} |
Destroy the volume and public URL; restore points are kept for seven days |
RestoreManagedDatabase |
POST /control/v1/orgs/{org_id}/databases/{database_id}:restore |
Replace the contents of a live or deleted database with a restore point |
ListDatabaseRestorePoints |
GET /control/v1/orgs/{org_id}/databases/{database_id}/restore-points |
List verified restore points, newest first |
CreateDatabaseRestorePoint |
POST /control/v1/orgs/{org_id}/databases/{database_id}/restore-points |
Request a restore point of the current data |
SetDatabaseAttachment |
PUT /control/v1/orgs/{org_id}/databases/{database_id}/agents/{agent_host_id} |
Attach or detach an Agent Host with read, write, or subscribe actions |
ListDatabaseAttachments |
GET /control/v1/orgs/{org_id}/databases/{database_id}/agents |
List attached Agent Hosts |
SubmitDatabaseRelease |
POST /control/v1/orgs/{org_id}/databases/{database_id}/releases |
Submit a release manifest |
ApproveDatabaseRelease |
POST /control/v1/orgs/{org_id}/databases/{database_id}/releases/{release_id}:approve |
Approve the exact digest of a destructive release |
ListDatabaseReleases |
GET /control/v1/orgs/{org_id}/databases/{database_id}/releases |
Release history with failure reasons |
GetDatabaseManifest |
GET /control/v1/orgs/{org_id}/databases/{database_id}/manifest |
Read the active or a named release manifest |
ProposeDatabaseSchema |
POST /control/v1/orgs/{org_id}/databases/{database_id}/schema:propose |
Prepare a Git patch or pull request for a schema change |
Database methods accept a Tarka account access token or a tk_live_ key with
the databases scope. Reads need organization membership; changes need an
owner, admin, or operator. MCP tools do not offer DeleteManagedDatabase or
RestoreManagedDatabase; an OAuth connection such as a CLI login with write
access may call them.
Deletion, restore, and restore-point creation return as soon as they are
recorded; poll GetManagedDatabase for state, operation_error, and
backup_requested_at. A deleted database keeps its ID and name reserved until
restorable_until. Restoring makes the restore point's release active again,
and writes made after the point are lost.
DatabaseService is served at grpc.tarka.rest:443. Every request names its
org_id and database_id; the first authorized request starts a sleeping
database.
| Method | REST route | Ability |
|---|---|---|
ListRecords |
GET .../collections/{collection}/records |
Page, sort, filter, and expand records |
GetRecord |
GET .../collections/{collection}/records/{record_id} |
Read one record |
CreateRecord |
POST .../collections/{collection}/records |
Create a record with optional file parts |
UpdateRecord |
PATCH .../collections/{collection}/records/{record_id} |
Change the given values and files |
DeleteRecord |
DELETE .../collections/{collection}/records/{record_id} |
Delete a record and its files |
BatchRecords |
POST .../records:batch |
Apply up to 50 writes in one transaction |
GetDatabaseHealth |
GET .../health |
Probe the running database |
DownloadRecordFile |
gRPC server stream | Stream a stored file or a byte range of it |
OpenRealtime |
gRPC server stream | Receive committed record changes |
SetRealtimeSubscriptions |
gRPC | Replace the topics of an open change stream |
Routes are relative to /control/v1/orgs/{org_id}/databases/{database_id}.
Organization owners, admins, and operators administer data and are not
restricted by collection rules. Project identity tokens act as an application
user: collection rules and the database permissions granted in the project
realm apply. Attached agents additionally need the matching attachment action.
A rejected write carries a RecordError status detail with per-field codes.
Each database also answers PocketBase-compatible HTTP under
/control/v1/orgs/{org_id}/databases/{database_id}/data/api/ and, when public
HTTPS is enabled, at its generated .tarka.run name. Those endpoints translate
to DatabaseService; contracts/databases
pins the translation. Use them from browsers and for file downloads and
realtime over HTTP.
Jobs, sandboxes and Agent Hosts run in Europe. Check organization-scoped product and location discovery and obtain an available compute quote before creation. Contract definitions alone do not enable a runtime; product approval, billing and shared capacity checks still apply.
Omitting a location selects the current per-product default reported by
ListLocations. Its capabilities distinguish the default, availability for
new resources, and support for existing resources. Explicit placement is a hard
constraint; a closed location fails instead of silently selecting another pool.
The chosen location is returned in the quote and
cannot change during retries or a failed launch. Existing resources retain
placement. A location list is not a reservation.
Jobs request CPU, memory and ephemeral scratch through JobResources. Zero
fields select 1000 millicores, 1024 MiB RAM and 1024 MiB scratch; explicit values
must meet the bounds documented in the protobuf. Images are resolved to a
permitted immutable digest before execution; embedded registry credentials,
privileged/host access and arbitrary extension-field runtime overrides are
not accepted. Jobs currently accept the configured public-registry allowlist;
org-private Tarka registry support will be documented after its runtime rollout.
A job's idempotency key retries the same mutation for 24 hours; changed content with the same key is rejected. Creating a new revision of an active job is a conflict. The default is one On-Demand attempt. Repeated attempts and Spot are explicit opt-ins for workloads whose external effects can safely repeat. Infrastructure retries are bounded to three attempts and wait for confirmed termination of prior work; queue delivery or a lost heartbeat does not imply permission to execute again. Nonzero exit status and execution timeout do not retry. Queue/setup time is free; reservation and usage account for the requested attempt budget and actual execution, respectively.
Cancellation can return STOPPING while work terminates. Terminal metadata
remains available after logs expire. Customer logs have seven-day retention;
GetJobRunResult rechecks access and returns a log download valid for at most
five minutes. Treat that URL as a bearer capability, and do not publish it.
Jobs use account access tokens and the organization role/product checks; these
additions do not make inference API keys valid for job-control methods.
| Method | REST route | Ability |
|---|---|---|
ListSandboxTemplates |
GET /control/v1/orgs/{org_id}/sandbox-templates |
List built-in and organization templates |
CreateSandboxTemplate |
POST /control/v1/orgs/{org_id}/sandbox-templates |
Build a dependency-pinned Python or Node.js template |
GetSandboxTemplate |
GET /control/v1/orgs/{org_id}/sandbox-templates/{template_id} |
Read template build state |
DeleteSandboxTemplate |
DELETE /control/v1/orgs/{org_id}/sandbox-templates/{template_id} |
Retire an unused custom template |
ListSandboxes |
GET /control/v1/orgs/{org_id}/sandboxes |
List non-deleted sandboxes |
CreateSandbox |
POST /control/v1/orgs/{org_id}/sandboxes |
Start a sandbox from a ready template |
GetSandbox |
GET /control/v1/orgs/{org_id}/sandboxes/{sandbox_id} |
Read sandbox lifecycle state |
DeleteSandbox |
DELETE /control/v1/orgs/{org_id}/sandboxes/{sandbox_id} |
Idempotently stop and delete a sandbox |
Execute |
POST /control/v1/orgs/{org_id}/sandboxes/{sandbox_id}:execute |
Execute one source-code payload |
GetExecution |
GET /control/v1/orgs/{org_id}/sandboxes/{sandbox_id}/executions/{execution_id} |
Read execution state and retained output |
Sandbox template creation, sandbox creation, and execution accept
idempotency_key; the same key and request body return the original resource
for 24 hours. Reusing a key with different content is rejected. Execution
stdout and stderr are retained for 15 minutes.
REST authentication middleware returns a compact JSON body such as
{"error":"invalid_token"}. Errors emitted after protobuf dispatch use the
standard gRPC-Gateway status object. Stable error codes are documented in
protobuf comments and implementation documentation; clients should branch on
HTTP/gRPC status and the machine-readable message, not on prose.
| HTTP | gRPC | Typical meaning |
|---|---|---|
400 |
INVALID_ARGUMENT |
Invalid field, unknown scope, or validation limit |
401 |
UNAUTHENTICATED |
Missing, expired, malformed, or unknown bearer token |
403 |
PERMISSION_DENIED |
Account, membership, role, entitlement, scope, or organization mismatch |
404 |
NOT_FOUND |
Visible resource does not exist |
409 |
ALREADY_EXISTS, FAILED_PRECONDITION, or ABORTED |
Name conflict or lifecycle precondition |
429 |
RESOURCE_EXHAUSTED |
Quota, rate, or cluster-capacity limit |
503 |
UNAVAILABLE |
Required control dependency is unavailable |
The complete field-level contract is in
proto/tarka/provisioning/v1, and the generated
REST description is
openapi/tarka-control-v1.swagger.json.
Existing OpenAI clients can call inference by changing only their base URL and key:
from openai import OpenAI
client = OpenAI(
base_url="https://tarka.rest/v1",
api_key="tk_live_...",
)
completion = client.chat.completions.create(
model="himalaya-q8",
messages=[{"role": "user", "content": "Reply with READY."}],
)The Responses API uses the same client and base URL:
response = client.responses.create(
model="himalaya-q8",
input="Reply with READY.",
)
print(response.output_text)For OCR through the same OpenAI-compatible method, select an OCR model and send an inline image as a standard multimodal content part:
completion = client.chat.completions.create(
model="glm-ocr-nepali",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Extract all text from this image."},
{
"type": "image_url",
"image_url": {"url": "data:image/png;base64,..."},
},
],
}],
)OCR images must be inline base64 values or base64 data URLs. Remote image URLs
are rejected. OCR requests require a customer key with the utilities scope,
including requests sent through /chat/completions.
Tarka implements the subset documented in
openapi/tarka-inference-v1.openapi.json; OpenAI endpoints absent from that
document are not part of Tarka's stable public contract.
A useful skill can be just a Markdown file and a small script. The
tarka-control-api example shows how to
teach Claude Code or Codex to use Tarka's entire public Control API:
examples/tarka-control-api/
├── SKILL.md # When to use the skill and how to work with the API
└── scripts/request.py # Authenticated HTTP requests using Python's standard library
The skill explains organization selection and API workflows; the helper handles HTTP requests. Exact routes and fields come from the existing public contract, so there is no second endpoint catalog to maintain. Copy the folder, adjust the description and instructions for your workflow, and you have your own skill.
You need Python 3.9+ and an existing Tarka account access token. A tk_live_
inference key cannot access the general Control API; sandbox-scoped keys can
access SandboxService only. This example does not implement login or token
refresh. Supply the token through your environment, for example with this
hidden terminal prompt, then run a read-only request from the API repo root:
export TARKA_ACCESS_TOKEN="$(python3 -c 'from getpass import getpass; print(getpass("Tarka account access token: "))')"
python3 examples/tarka-control-api/scripts/request.py GET /meStart your agent from that terminal so it inherits the environment. Copy the whole folder into your project's skills directory (replace the project path below):
# Codex
mkdir -p /path/to/your-project/.agents/skills
cp -R examples/tarka-control-api /path/to/your-project/.agents/skills/
# Claude Code
mkdir -p /path/to/your-project/.claude/skills
cp -R examples/tarka-control-api /path/to/your-project/.claude/skills/See the official Codex skill documentation and Claude Code skill documentation for discovery and invocation options. The copied skill uses public documentation links and works without keeping this repository cloned.
Try prompts such as:
- "Use the tarka-control-api skill to list my organizations and their resources."
- "Use the tarka-control-api skill to create an OpenClaw Agent Host named demo in my development organization."
- "Use the tarka-control-api skill to run a Python hello-world in a sandbox in my development organization, then delete the sandbox."
The latter two prompts create resources. Keep credentials out of chat and committed files; the skill explains how to save one-time credential responses privately. For a narrower skill, change the description and keep only the workflow guidance your use case needs.
Install Buf, clone a tagged release, and use a generation template for your language:
git clone --branch v1.3.0 --depth 1 https://github.com/TarkaHQ/api.git tarka-api
cd tarka-api
buf lint
buf build
buf generate --template path/to/your/buf.gen.yamlA minimal Python template, for example, is:
version: v2
plugins:
- remote: buf.build/protocolbuffers/python
out: gen/python
- remote: buf.build/grpc/python
out: gen/pythonPin remote plugin versions in production generation templates. Buf resolves the
Google API annotations declared in buf.lock; standard protobuf well-known
types are supplied by the Protocol Buffers toolchain.
You can also use protoc directly. Add proto/ and the Google API common
protos to its include paths, then compile the files under
proto/tarka/provisioning/v1 and proto/tarka/inference/v1 with your
language's gRPC plugin.
With Buf installed:
make verifyWith only Docker installed:
make verify-dockerWhen changing the protobuf contract, regenerate the control OpenAPI document
and include it in the same pull request. Validate authored inference OpenAPI
changes as part of the same review. See
CONTRIBUTING.md and VERSIONING.md before
proposing a change.
gRPC is the primary control-plane contract. Control REST routes are generated from
google.api.http annotations in the same protobuf definitions, so the REST
control surface cannot become an independent source of truth. The separate
OpenAI-compatible inference surface is described by an authored OpenAPI 3.1
document because its wire format is HTTP/JSON and SSE rather than protobuf.
Apache License 2.0. See LICENSE.
POST /control/v1/orgs/{org_id}/compute-quotes returns a five-minute quote in
billing currency, including normalized allocation, runtime/network caps,
minimum charge, maximum reservation and immutable price/FX version. Creation
uses accepted_quote_id and the returned location. Existing resources retain
placement and billing. Agent Host previews include admission with a
timestamp, availability and reason; they reserve no capacity. Availability can change before atomic
creation. The console shows quotes before creation.
GET /control/v1/orgs/{org_id}/usage-policy reports allowances, inventory and
an estimate. Only an owner can accept the current estimate using /accept, and
only after shadow metering and backend enforcement qualify. Existing data is
never billed retroactively. At exhausted funds data is read-only and retained;
there is no automatic deletion or unpaid debt. Product availability remains a
separate gate; these contracts do not announce customer launch.
PrepareAgentHostSecrets creates an organization/name/revision-bound handoff
and returns an authenticated console URL. A person uploads a .env or JSON
string-map file through the console or the bundled
secrets.py helper. Only direct
HTTP exposes UploadAgentHostSecrets; MCP exposes preparation and metadata
reads, never secret values. Once GetAgentHostSecrets reports ready, pass
secrets_bundle_id to CreateAgentHost. The one-hour bundle is consumed in the
same transaction as successful admission. Rejected admission does not consume
it. A revision change requires a new bundle. Values are never returned by the
metadata endpoints; ordinary direct-HTTP inline clients remain compatible.
The organization-scoped /control/v1/orgs/{org_id}/source/* contract adds
GitHub App authorization, Hosted Git connections, source targets and build
history/logs. These capabilities remain unavailable until the isolated runtime
and registry rollout is qualified; publishing this contract does not enable
customer Dockerfiles.
GetSourceCapabilities reports current connection/build availability. Use
PreviewSource to resolve a selected branch to one immutable commit, discover a
Compose file and review its build services. It executes no source and creates
no host. The returned configuration records the repository-relative Compose
path so builds and later deployment use the same source snapshot.
After a build succeeds, PrepareSourceDeployment returns a complete Compose
revision with every build service replaced by its organization-owned immutable
image. Existing image-only services and runtime settings are preserved. Pass
that revision through the ordinary host quote and apply flow; this endpoint
does not grant deployment or price consent.
An organization administrator authorizes GitHub in their browser and chooses repositories visible to both their GitHub identity and the App. Credentials remain server-side. Installation IDs alone never grant access. Repository removal or installation revocation cancels queued work and stops active work.
Targets bind a repository, exact branch and local Dockerfile/context per service. Builds initially produce linux/amd64 images. They accept no forwarded secret, SSH key, private external dependency credential or privileged build entitlement. Queue requests are idempotent. Included allowance is five starts per organization per rolling 24 hours; platform failures do not consume it. Runtime is capped at 15 minutes and two builds globally. Monetary build charging is inactive.
A successful build returns immutable images for normal host creation/apply. Building does not itself create a host or authorize its price. Compose services must all finish before a revision is applied; failed builds preserve the running host. Build logs are untrusted plain text and must be escaped by clients.