API Documentation
Complete reference for every Yuga endpoint. Train your model, query it, manage sessions, register tools, and run autonomous pipelines — all from a single REST API on your own server.
https://yug.ygmarketplace.com/api/
Authentication
Every request must include your API key. Pass it as a request header or as a query parameter. The global admin key is the plain api_key value from config.php.
X-API-Key: yuga_live_…
Query: ?key=yuga_live_…
Admin key: plain api_key from config.php
Core
4 endpointsReturns the current state of a model: vocab size, training steps, last loss, crawl stats, and server base URL.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name to query (defaults to "default") (optional) |
* required
List all named model instances on this server.
Create a new named model. Each model has completely independent weights, vocabulary, and training data.
| Parameter | Type | Description |
|---|---|---|
| model | string | Name for the new model (alphanumeric, dashes, underscores) |
* required
Permanently delete a model and all of its training data. This action cannot be undone.
| Parameter | Type | Description |
|---|---|---|
| model | string | Name of the model to delete |
* required
Chat & Generation
10 endpointsContext-aware Q&A with persistent session memory. Uses BM25 retrieval to ground every answer in your trained content.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| message | string | User message |
| session_id | string | Session ID for multi-turn memory. Omit to start a fresh context. (optional) |
| temperature | float | Sampling temperature 0–1. Default: 0.72 (optional) |
* required
ChatGPT-style chat backed by an optional external LLM. Accepts a full conversation history array for multi-turn context.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| message | string | Latest user message |
| history | array | Array of {role, content} objects for prior turns (optional) |
| max_tokens | int | Max tokens for LLM response (optional) |
| llm_model | string | Override the LLM backend model name (optional) |
* required
Chain-of-thought reasoning. Decomposes the question into sub-problems, retrieves evidence for each, then synthesises a grounded answer.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| question | string | Question to reason about |
| temperature | float | Sampling temperature (optional) |
| trace | bool | Set true to include the full thinking trace in the response (optional) |
* required
Multi-hop reasoning. Follows chains of evidence across retrieved passages — ideal for questions that span multiple documents.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| question | string | Question to answer |
| temperature | float | Sampling temperature (optional) |
| max_hops | int | Maximum reasoning hops (default 3) (optional) |
| refine | bool | Refine the answer after all hops (optional) |
* required
Autonomous agent loop. Yuga plans its own actions toward the goal, executing search/reason/tool steps until satisfied (up to max_steps).
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| goal | string | High-level goal for the agent to pursue |
| max_steps | int | Max action steps 1–10 (default 5) (optional) |
| temperature | float | Sampling temperature (optional) |
| max_hops | int | Max hops per reason step (optional) |
| refine | bool | Refine final answer (optional) |
* required
Higher-quality text generation using beam search. Produces more coherent multi-sentence output than greedy or top-p sampling.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| prompt | string | Text prompt to continue |
| max_tokens | int | Maximum tokens to generate (optional) |
| beam_width | int | Number of beams to maintain (default 3) (optional) |
| length_penalty | float | Penalise shorter completions (default 0.9) (optional) |
* required
Multi-mode text generation with fine-grained control over sampling parameters.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| mode | string | complete (default) | expand | best_of | fill (optional) |
| prompt | string | Input prompt or template |
| temperature | float | Sampling temperature (optional) |
| top_p | float | Nucleus sampling threshold (optional) |
| rep_penalty | float | Repetition penalty (optional) |
| max_tokens | int | Max tokens to generate (optional) |
| n | int | Number of candidates for best_of mode (optional) |
* required
Character-level text generation from the YugaGen checkpoint. Requires a trained checkpoint (see yugagen_status).
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| prompt | string | Text prompt |
| max_chars | int | Max characters to generate (optional) |
| temperature | float | Sampling temperature (optional) |
| top_p | float | Nucleus sampling threshold (optional) |
* required
Training status of the YugaGen checkpoint: steps completed, current and best loss, vocabulary size, parameter count, and architecture string.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
* required
List all trained YugaGen checkpoints with their stats and file size.
Training
6 endpointsTrain the model on any raw text string. Minimum 10 characters. Use the source parameter to tag the provenance of the content.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| text | string | Raw text to train on (min 10 chars) |
| source | string | Label describing where this content came from (optional) |
* required
Fetch a single URL, extract its text content, and train the model on it.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| url | string | URL to fetch and learn from |
* required
Crawl a site's homepage and sitemap (1 level deep), then train on all discovered pages.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| url | string | Site root URL to crawl |
| max_pages | int | Maximum pages to crawl. Default: 30. Max: 100 (optional) |
* required
Recursive BFS full-site crawl with configurable depth. Discovers and trains on every reachable page within the domain.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| url | string | Seed URL to start crawling from |
| max_pages | int | Max pages to process (default 100) (optional) |
| max_depth | int | Max BFS depth (default 4) (optional) |
| train_steps | int | Training steps per page batch (optional) |
| reset | bool | Clear crawl history before starting (optional) |
* required
Multi-format document ingestion. Accepts PDF, DOCX, CSV, JSON, and TXT either as a file upload (multipart) or by URL/text.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| url | string | Remote URL of a document to fetch and ingest (optional) |
| text | string | Raw text content to ingest directly (optional) |
| source | string | Label for this content (used with text) (optional) |
| file_path | string | Server-side absolute path to a file (optional) |
| file | file | Multipart file upload field — PDF/DOCX/CSV/JSON/TXT (optional) |
* required
Add content to the SmartChat BM25 knowledge base AND simultaneously train transformer weights.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| text | string | Content to add to knowledge base and train on |
| source | string | Label describing the content source (optional) |
* required
Web Search
1 endpointLive web search with real-time content fetching — Perplexity-style. Optionally generate a natural language answer from the retrieved sources.
| Parameter | Type | Description |
|---|---|---|
| query | string | Search query |
| sources | int | Number of sources to retrieve (1–10, default 5) (optional) |
| model | string | Model name (used if generate is true) (optional) |
| generate | bool | Set true to synthesise a natural language answer from sources (optional) |
* required
Sessions
4 endpointsSessions give chat persistent multi-turn memory. Create a session once, then pass the returned session_id on every subsequent call to maintain context across requests.
Create a new conversation session associated with a model.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
* required
Retrieve the last N turns from a session as a structured history array.
| Parameter | Type | Description |
|---|---|---|
| session_id | string | Session ID to retrieve history for |
| last_n | int | Number of most recent turns to return (default 20) (optional) |
* required
Permanently delete a session and free its stored context memory.
| Parameter | Type | Description |
|---|---|---|
| session_id | string | Session ID to terminate |
* required
Voice command and knowledge Q&A router. Detects device intents (play, set, open, call, turn on/off) vs knowledge questions and returns either a structured device action payload or a natural language reply.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| message | string | User message or voice command text |
| session_id | string | Session ID for conversation memory (optional) |
* required
Tools & Pipelines
5 endpointsRegister HTTP callback tools that Yuga can auto-select and call based on natural language queries — self-hosted function calling with no OpenAI required. Pipelines chain multiple steps into deterministic workflows.
Register an external tool that Yuga can call. The description is used for semantic matching against user queries.
| Parameter | Type | Description |
|---|---|---|
| name | string | Unique tool name (used when calling) |
| description | string | Plain English description — used for semantic matching |
| type | string | php | webhook | get | sql |
| endpoint | string | URL or handler path the tool calls |
| schema | object | Parameter schema object describing tool inputs (optional) |
* required
List all registered tools and their metadata.
Call a specific registered tool by name with explicit parameters.
| Parameter | Type | Description |
|---|---|---|
| tool | string | Registered tool name to invoke |
| params | object | Parameter object to pass to the tool |
* required
Auto-select the best matching tool for a natural language query using semantic similarity, then execute it.
| Parameter | Type | Description |
|---|---|---|
| query | string | Natural language query to match against registered tools |
* required
Execute a deterministic multi-step workflow. Each step receives the previous step's output as {output}. Step types: search, tool, ingest, generate, reason, transform.
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name |
| input | string | Initial input passed to the first step |
| steps | array | Array of step objects. Each step has a type and optional params. |
| vars | object | Variable map injected into step templates (optional) |
* required
Error Codes
| Status | Code | Meaning |
|---|---|---|
| 400 | bad_request | Missing or invalid request body. Check your JSON payload and required parameters. |
| 401 | unauthorized | Invalid, missing, or expired API key. Pass your key in X-API-Key header or ?key= param. |
| 429 | rate_limited | Daily API call limit exceeded for your plan. Limit resets at midnight UTC. Upgrade for higher limits. |
| 404 | unknown_action | The action parameter does not match any known endpoint. Check spelling. |
| 500 | server_error | Internal server error. Check your server error log. Usually caused by missing model weights or file permissions. |
All error responses include a JSON body: {"error": "message", "code": "slug"}