Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,24 @@ def parse_endpoints(spec: dict) -> Dict[str, List[Tuple[str, str, str, str]]]:
return endpoints_by_tag


def generate_endpoint_url(operation_id: str, tag: str, path: str) -> str:
"""Generate the Mintlify URL for an endpoint based on its operation ID and tag."""
# Map tags to URL segments
tag_mapping = {
"Chat": "chat",
"Completions": "completions",
"Models": "models",
"Jobs": "jobs",
"Training": "training",
"Inference": "inference",
"Health": "health",
"Service": "service",
}

tag_segment = tag_mapping.get(tag, tag.lower().replace(" ", "-"))

# Convert operation_id to URL slug
# Remove the suffix like _get, _post, etc.
url_slug = re.sub(r'_(get|post|put|delete|patch)$', '', operation_id)
# Replace underscores with hyphens
url_slug = url_slug.replace('_', '-')

# If no operation_id, use the path to generate a slug
if not url_slug:
# Convert path like /v1/chat/completions to chat-completions
def generate_endpoint_url(summary: str, tag: str, path: str) -> str:
"""Generate the Mintlify URL for an endpoint based on its summary and tag.

Mintlify generates URL slugs from the operation summary (title), not operationId.
"""
# Convert tag to URL segment (Mintlify lowercases and hyphenates)
tag_segment = tag.lower().replace(" ", "-")

# Convert summary to URL slug (Mintlify lowercases and hyphenates the title)
# Example: "Create Chat Completion" -> "create-chat-completion"
if summary:
url_slug = summary.lower().replace(" ", "-")
# Remove any non-alphanumeric characters except hyphens
url_slug = re.sub(r'[^a-z0-9-]', '', url_slug)
# Collapse multiple hyphens
url_slug = re.sub(r'-+', '-', url_slug)
else:
# Fallback: use path to generate a slug
url_slug = path.strip('/').replace('/v1/', '').replace('/', '-')

return f"https://docs.wandb.ai/training/api-reference/{tag_segment}/{url_slug}"
Expand All @@ -104,7 +97,7 @@ def generate_endpoints_section(endpoints: Dict[str, List[Tuple[str, str, str, st
lines.append(f"\n### {category}\n\n")

for method, path, operation_id, summary in endpoints[category]:
url = generate_endpoint_url(operation_id, category, path)
url = generate_endpoint_url(summary, category, path)
lines.append(f"- **[{method} {path}]({url})** - {summary}\n")

return "".join(lines)
Expand Down
23 changes: 23 additions & 0 deletions training/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@ https://api.training.wandb.ai/v1

### models

- **[POST /v1/preview/models](https://docs.wandb.ai/training/api-reference/models/create-model-v1-preview-models)** - Create Model
- **[DELETE /v1/preview/models/{model_id}](https://docs.wandb.ai/training/api-reference/models/delete-model-v1-preview-models--model-id-)** - Delete Model
- **[DELETE /v1/preview/models/{model_id}/checkpoints](https://docs.wandb.ai/training/api-reference/models/delete-model-checkpoints-v1-preview-models--model-id--checkpoints)** - Delete Model Checkpoints
- **[GET /v1/preview/models/{model_id}/checkpoints](https://docs.wandb.ai/training/api-reference/models/list-model-checkpoints-v1-preview-models--model-id--checkpoints)** - List Model Checkpoints
- **[POST /v1/preview/models/{model_id}/log](https://docs.wandb.ai/training/api-reference/models/log-v1-preview-models--model-id--log)** - Log

### training-jobs

- **[POST /v1/preview/training-jobs](https://docs.wandb.ai/training/api-reference/training-jobs/create-training-job-v1-preview-training-jobs)** - Create Training Job
- **[GET /v1/preview/training-jobs/{training_job_id}](https://docs.wandb.ai/training/api-reference/training-jobs/get-training-job-v1-preview-training-jobs--training-job-id-)** - Get Training Job
- **[GET /v1/preview/training-jobs/{training_job_id}/events](https://docs.wandb.ai/training/api-reference/training-jobs/get-training-job-events-v1-preview-training-jobs--training-job-id--events)** - Get Training Job Events

### Uncategorized

- **[GET /v1/health](https://docs.wandb.ai/training/api-reference/uncategorized/health-check-v1-health)** - Health Check
- **[GET /v1/system-check](https://docs.wandb.ai/training/api-reference/uncategorized/system-check-v1-system-check)** - System Check
### chat-completions

- **[POST /v1/chat/completions](https://docs.wandb.ai/training/api-reference/chat-completions/create-chat-completion-v1-chat-completions)** - Create Chat Completion
- **[POST /v1/chat/completions/](https://docs.wandb.ai/training/api-reference/chat-completions/create-chat-completion-v1-chat-completions-)** - Create Chat Completion

### models

- **[POST /v1/preview/models](https://docs.wandb.ai/training/api-reference/models/create-model-v1-preview-models)** - Create Model
- **[DELETE /v1/preview/models/{model_id}/checkpoints](https://docs.wandb.ai/training/api-reference/models/delete-model-checkpoints-v1-preview-models--model-id--checkpoints)** - Delete Model Checkpoints
- **[GET /v1/preview/models/{model_id}/checkpoints](https://docs.wandb.ai/training/api-reference/models/list-model-checkpoints-v1-preview-models--model-id--checkpoints)** - List Model Checkpoints
Expand Down
Loading