Skip to content

Commit b6a5bcc

Browse files
docs: api separation (#3630)
# What does this PR do? First step towards cleaning up the API reference section of the docs. - Separates API reference into 3 sections: stable (`v1`), experimental (`v1alpha` and `v1beta`), and deprecated (`deprecated=True`) - Each section is accessible via the dropdown menu and `docs/api-overview` <img width="1237" height="321" alt="Screenshot 2025-09-30 at 5 47 30 PM" src="https://github.com/user-attachments/assets/fe0e498c-b066-46ed-a48e-4739d3b6724c" /> <img width="860" height="510" alt="Screenshot 2025-09-30 at 5 47 49 PM" src="https://github.com/user-attachments/assets/a92a8d8c-94bf-42d5-9f5b-b47bb2b14f9c" /> - Deprecated APIs: Added styling to the sidebar, and a notice on the endpoint pages <img width="867" height="428" alt="Screenshot 2025-09-30 at 5 47 43 PM" src="https://github.com/user-attachments/assets/9e6e050d-c782-461b-8084-5ff6496d7bd9" /> Closes #3628 TODO in follow-up PRs: - Add the ability to annotate API groups with supplementary content (so we can have longer descriptions of complex APIs like Responses) - Clean up docstrings to show API endpoints (or short semantic titles) in the sidebar ## Test Plan - Local testing - Made sure API conformance test still passes
1 parent 7f1a33f commit b6a5bcc

File tree

15 files changed

+35908
-26088
lines changed

15 files changed

+35908
-26088
lines changed

docs/docs/api-overview.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# API Reference Overview
2+
3+
The Llama Stack provides a comprehensive set of APIs organized by stability level to help you choose the right endpoints for your use case.
4+
5+
## 🟢 Stable APIs
6+
7+
**Production-ready APIs with backward compatibility guarantees.**
8+
9+
These APIs are fully tested, documented, and stable. They follow semantic versioning principles and maintain backward compatibility within major versions. Recommended for production applications.
10+
11+
[**Browse Stable APIs →**](./api/llama-stack-specification)
12+
13+
**Key Features:**
14+
- ✅ Backward compatibility guaranteed
15+
- ✅ Comprehensive testing and validation
16+
- ✅ Production-ready reliability
17+
- ✅ Long-term support
18+
19+
---
20+
21+
## 🟡 Experimental APIs
22+
23+
**Preview APIs that may change before becoming stable.**
24+
25+
These APIs include v1alpha and v1beta endpoints that are feature-complete but may undergo changes based on feedback. Great for exploring new capabilities and providing feedback.
26+
27+
[**Browse Experimental APIs →**](./api-experimental/llama-stack-specification-experimental-apis)
28+
29+
**Key Features:**
30+
- 🧪 Latest features and capabilities
31+
- 🧪 May change based on user feedback
32+
- 🧪 Active development and iteration
33+
- 🧪 Opportunity to influence final design
34+
35+
---
36+
37+
## 🔴 Deprecated APIs
38+
39+
**Legacy APIs for migration reference.**
40+
41+
These APIs are deprecated and will be removed in future versions. They are provided for migration purposes and to help transition to newer, stable alternatives.
42+
43+
[**Browse Deprecated APIs →**](./api-deprecated/llama-stack-specification-deprecated-apis)
44+
45+
**Key Features:**
46+
- ⚠️ Will be removed in future versions
47+
- ⚠️ Migration guidance provided
48+
- ⚠️ Use for compatibility during transition
49+
- ⚠️ Not recommended for new projects
Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
---
2-
description: "Agents API for creating and interacting with agentic systems.
2+
description: "Agents
33
4-
Main functionalities provided by this API:
5-
- Create agents with specific instructions and ability to use tools.
6-
- Interactions with agents are grouped into sessions (\"threads\"), and each interaction is called a \"turn\".
7-
- Agents can be provided with various tools (see the ToolGroups and ToolRuntime APIs for more details).
8-
- Agents can be provided with various shields (see the Safety API for more details).
9-
- Agents can also use Memory to retrieve information from knowledge bases. See the RAG Tool and Vector IO APIs for more details."
4+
APIs for creating and interacting with agentic systems."
105
sidebar_label: Agents
116
title: Agents
127
---
@@ -15,13 +10,8 @@ title: Agents
1510

1611
## Overview
1712

18-
Agents API for creating and interacting with agentic systems.
13+
Agents
1914

20-
Main functionalities provided by this API:
21-
- Create agents with specific instructions and ability to use tools.
22-
- Interactions with agents are grouped into sessions ("threads"), and each interaction is called a "turn".
23-
- Agents can be provided with various tools (see the ToolGroups and ToolRuntime APIs for more details).
24-
- Agents can be provided with various shields (see the Safety API for more details).
25-
- Agents can also use Memory to retrieve information from knowledge bases. See the RAG Tool and Vector IO APIs for more details.
15+
APIs for creating and interacting with agentic systems.
2616

2717
This section contains documentation for all available providers for the **agents** API.

docs/docusaurus.config.ts

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,27 @@ const config: Config = {
5555
label: 'Docs',
5656
},
5757
{
58-
type: 'docSidebar',
59-
sidebarId: 'apiSidebar',
60-
position: 'left',
58+
type: 'dropdown',
6159
label: 'API Reference',
60+
position: 'left',
61+
to: '/docs/api-overview',
62+
items: [
63+
{
64+
type: 'docSidebar',
65+
sidebarId: 'stableApiSidebar',
66+
label: '🟢 Stable APIs',
67+
},
68+
{
69+
type: 'docSidebar',
70+
sidebarId: 'experimentalApiSidebar',
71+
label: '🟡 Experimental APIs',
72+
},
73+
{
74+
type: 'docSidebar',
75+
sidebarId: 'deprecatedApiSidebar',
76+
label: '🔴 Deprecated APIs',
77+
},
78+
],
6279
},
6380
{
6481
href: 'https://github.com/llamastack/llama-stack',
@@ -83,7 +100,7 @@ const config: Config = {
83100
},
84101
{
85102
label: 'API Reference',
86-
to: '/docs/api/llama-stack-specification',
103+
to: '/docs/api-overview',
87104
},
88105
],
89106
},
@@ -170,7 +187,7 @@ const config: Config = {
170187
id: "openapi",
171188
docsPluginId: "classic",
172189
config: {
173-
llamastack: {
190+
stable: {
174191
specPath: "static/llama-stack-spec.yaml",
175192
outputDir: "docs/api",
176193
downloadUrl: "https://raw.githubusercontent.com/meta-llama/llama-stack/main/docs/static/llama-stack-spec.yaml",
@@ -179,6 +196,24 @@ const config: Config = {
179196
categoryLinkSource: "tag",
180197
},
181198
} satisfies OpenApiPlugin.Options,
199+
experimental: {
200+
specPath: "static/experimental-llama-stack-spec.yaml",
201+
outputDir: "docs/api-experimental",
202+
downloadUrl: "https://raw.githubusercontent.com/meta-llama/llama-stack/main/docs/static/experimental-llama-stack-spec.yaml",
203+
sidebarOptions: {
204+
groupPathsBy: "tag",
205+
categoryLinkSource: "tag",
206+
},
207+
} satisfies OpenApiPlugin.Options,
208+
deprecated: {
209+
specPath: "static/deprecated-llama-stack-spec.yaml",
210+
outputDir: "docs/api-deprecated",
211+
downloadUrl: "https://raw.githubusercontent.com/meta-llama/llama-stack/main/docs/static/deprecated-llama-stack-spec.yaml",
212+
sidebarOptions: {
213+
groupPathsBy: "tag",
214+
categoryLinkSource: "tag",
215+
},
216+
} satisfies OpenApiPlugin.Options,
182217
} satisfies Plugin.PluginOptions,
183218
},
184219
],

docs/openapi_generator/generate.py

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,40 +34,52 @@ def str_presenter(dumper, data):
3434
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style=style)
3535

3636

37-
def main(output_dir: str):
38-
output_dir = Path(output_dir)
39-
if not output_dir.exists():
40-
raise ValueError(f"Directory {output_dir} does not exist")
37+
def generate_spec(output_dir: Path, stability_filter: str = None, main_spec: bool = False):
38+
"""Generate OpenAPI spec with optional stability filtering."""
4139

42-
# Validate API protocols before generating spec
43-
return_type_errors = validate_api()
44-
if return_type_errors:
45-
print("\nAPI Method Return Type Validation Errors:\n")
46-
for error in return_type_errors:
47-
print(error, file=sys.stderr)
48-
sys.exit(1)
49-
now = str(datetime.now())
50-
print(
51-
"Converting the spec to YAML (openapi.yaml) and HTML (openapi.html) at " + now
52-
)
53-
print("")
40+
if stability_filter:
41+
title_suffix = {
42+
"stable": " - Stable APIs" if not main_spec else "",
43+
"experimental": " - Experimental APIs",
44+
"deprecated": " - Deprecated APIs"
45+
}.get(stability_filter, f" - {stability_filter.title()} APIs")
46+
47+
# Use main spec filename for stable when main_spec=True
48+
if main_spec and stability_filter == "stable":
49+
filename_prefix = ""
50+
else:
51+
filename_prefix = f"{stability_filter}-"
52+
53+
description_suffix = {
54+
"stable": "\n\n**✅ STABLE**: Production-ready APIs with backward compatibility guarantees.",
55+
"experimental": "\n\n**🧪 EXPERIMENTAL**: Pre-release APIs (v1alpha, v1beta) that may change before becoming stable.",
56+
"deprecated": "\n\n**⚠️ DEPRECATED**: Legacy APIs that may be removed in future versions. Use for migration reference only."
57+
}.get(stability_filter, "")
58+
else:
59+
title_suffix = ""
60+
filename_prefix = ""
61+
description_suffix = ""
5462

5563
spec = Specification(
5664
LlamaStack,
5765
Options(
5866
server=Server(url="http://any-hosted-llama-stack.com"),
5967
info=Info(
60-
title="Llama Stack Specification",
68+
title=f"Llama Stack Specification{title_suffix}",
6169
version=LLAMA_STACK_API_V1,
62-
description="""This is the specification of the Llama Stack that provides
70+
description=f"""This is the specification of the Llama Stack that provides
6371
a set of endpoints and their corresponding interfaces that are tailored to
64-
best leverage Llama Models.""",
72+
best leverage Llama Models.{description_suffix}""",
6573
),
6674
include_standard_error_responses=True,
75+
stability_filter=stability_filter, # Pass the filter to the generator
6776
),
6877
)
6978

70-
with open(output_dir / "llama-stack-spec.yaml", "w", encoding="utf-8") as fp:
79+
yaml_filename = f"{filename_prefix}llama-stack-spec.yaml"
80+
html_filename = f"{filename_prefix}llama-stack-spec.html"
81+
82+
with open(output_dir / yaml_filename, "w", encoding="utf-8") as fp:
7183
y = yaml.YAML()
7284
y.default_flow_style = False
7385
y.block_seq_indent = 2
@@ -83,9 +95,36 @@ def main(output_dir: str):
8395
fp,
8496
)
8597

86-
with open(output_dir / "llama-stack-spec.html", "w") as fp:
98+
with open(output_dir / html_filename, "w") as fp:
8799
spec.write_html(fp, pretty_print=True)
88100

101+
print(f"Generated {yaml_filename} and {html_filename}")
102+
103+
def main(output_dir: str):
104+
output_dir = Path(output_dir)
105+
if not output_dir.exists():
106+
raise ValueError(f"Directory {output_dir} does not exist")
107+
108+
# Validate API protocols before generating spec
109+
return_type_errors = validate_api()
110+
if return_type_errors:
111+
print("\nAPI Method Return Type Validation Errors:\n")
112+
for error in return_type_errors:
113+
print(error, file=sys.stderr)
114+
sys.exit(1)
115+
116+
now = str(datetime.now())
117+
print(f"Converting the spec to YAML (openapi.yaml) and HTML (openapi.html) at {now}")
118+
print("")
119+
120+
# Generate main spec as stable APIs (llama-stack-spec.yaml)
121+
print("Generating main specification (stable APIs)...")
122+
generate_spec(output_dir, "stable", main_spec=True)
123+
124+
print("Generating other stability-filtered specifications...")
125+
generate_spec(output_dir, "experimental")
126+
generate_spec(output_dir, "deprecated")
127+
89128

90129
if __name__ == "__main__":
91130
fire.Fire(main)

0 commit comments

Comments
 (0)