Skip to content

Commit 424b575

Browse files
committed
docs: add testing guide with simulator ExternalModel CRDs and curl commands
1 parent 3523334 commit 424b575

1 file changed

Lines changed: 254 additions & 0 deletions

File tree

docs/testing-with-simulator.md

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
# Testing ExternalModel with the Simulator
2+
3+
This guide provides working CRDs and curl commands for testing ExternalModel
4+
body-based routing against the shared simulator (`llm-katan`). The simulator
5+
supports OpenAI Chat Completions and Anthropic Messages formats.
6+
7+
## Simulator Endpoint
8+
9+
```
10+
Host: 3-132-132-211.sslip.io
11+
Providers: openai, anthropic, azure, bedrock, vertexai
12+
```
13+
14+
Each provider type has its own API key:
15+
16+
| Provider | Key |
17+
|----------|-----|
18+
| openai | `llm-katan-openai-key` |
19+
| anthropic | `llm-katan-anthropic-key` |
20+
| azure | `llm-katan-azure-key` |
21+
| bedrock | `llm-katan-bedrock-key` |
22+
23+
## Secrets
24+
25+
```yaml
26+
apiVersion: v1
27+
kind: Secret
28+
metadata:
29+
name: sim-openai-key
30+
namespace: llm
31+
labels:
32+
inference.llm-d.ai/ipp-managed: "true"
33+
type: Opaque
34+
stringData:
35+
api-key: "llm-katan-openai-key"
36+
---
37+
apiVersion: v1
38+
kind: Secret
39+
metadata:
40+
name: sim-anthropic-key
41+
namespace: llm
42+
labels:
43+
inference.llm-d.ai/ipp-managed: "true"
44+
type: Opaque
45+
stringData:
46+
api-key: "llm-katan-anthropic-key"
47+
```
48+
49+
## ExternalProviders
50+
51+
```yaml
52+
apiVersion: inference.opendatahub.io/v1alpha1
53+
kind: ExternalProvider
54+
metadata:
55+
name: sim-openai
56+
namespace: llm
57+
spec:
58+
provider: openai
59+
endpoint: 3-132-132-211.sslip.io
60+
auth:
61+
type: apikey
62+
secretRef:
63+
name: sim-openai-key
64+
---
65+
apiVersion: inference.opendatahub.io/v1alpha1
66+
kind: ExternalProvider
67+
metadata:
68+
name: sim-anthropic
69+
namespace: llm
70+
spec:
71+
provider: anthropic
72+
endpoint: 3-132-132-211.sslip.io
73+
auth:
74+
type: apikey
75+
secretRef:
76+
name: sim-anthropic-key
77+
```
78+
79+
## ExternalModels
80+
81+
### 1. OpenAI Chat Completions (`/v1/chat/completions`)
82+
83+
```yaml
84+
apiVersion: inference.opendatahub.io/v1alpha1
85+
kind: ExternalModel
86+
metadata:
87+
name: sim-chat
88+
namespace: llm
89+
spec:
90+
externalProviderRefs:
91+
- ref:
92+
name: sim-openai
93+
targetModel: sim-chat
94+
apiFormat: openai-chat
95+
path: /v1/chat/completions
96+
weight: 100
97+
```
98+
99+
### 2. Anthropic Messages (`/v1/messages`)
100+
101+
```yaml
102+
apiVersion: inference.opendatahub.io/v1alpha1
103+
kind: ExternalModel
104+
metadata:
105+
name: sim-messages
106+
namespace: llm
107+
spec:
108+
externalProviderRefs:
109+
- ref:
110+
name: sim-anthropic
111+
targetModel: sim-messages
112+
apiFormat: messages
113+
path: /v1/messages
114+
weight: 100
115+
```
116+
117+
### 3. OpenAI Chat Completions (alternate — second model for multi-model testing)
118+
119+
```yaml
120+
apiVersion: inference.opendatahub.io/v1alpha1
121+
kind: ExternalModel
122+
metadata:
123+
name: sim-chat-2
124+
namespace: llm
125+
spec:
126+
externalProviderRefs:
127+
- ref:
128+
name: sim-openai
129+
targetModel: sim-chat-2
130+
apiFormat: openai-chat
131+
path: /v1/chat/completions
132+
weight: 100
133+
```
134+
135+
## MaaSModelRefs (required for MaaS governance)
136+
137+
```yaml
138+
apiVersion: maas.opendatahub.io/v1alpha1
139+
kind: MaaSModelRef
140+
metadata:
141+
name: sim-chat
142+
namespace: llm
143+
spec:
144+
modelRef:
145+
kind: ExternalModel
146+
name: sim-chat
147+
---
148+
apiVersion: maas.opendatahub.io/v1alpha1
149+
kind: MaaSModelRef
150+
metadata:
151+
name: sim-messages
152+
namespace: llm
153+
spec:
154+
modelRef:
155+
kind: ExternalModel
156+
name: sim-messages
157+
---
158+
apiVersion: maas.opendatahub.io/v1alpha1
159+
kind: MaaSModelRef
160+
metadata:
161+
name: sim-chat-2
162+
namespace: llm
163+
spec:
164+
modelRef:
165+
kind: ExternalModel
166+
name: sim-chat-2
167+
```
168+
169+
## Curl Commands
170+
171+
Set these variables first:
172+
173+
```bash
174+
export GATEWAY="https://maas.apps.ocp.nrt9w.sandbox311.opentlc.com"
175+
export API_KEY="sk-oai-18Zj600CNqbALti8I_rXCa3LQqaRLA8NbgROjRI3rS46vVWi6DUj5jctfcMYx"
176+
```
177+
178+
### Chat Completions (path-based routing)
179+
180+
```bash
181+
curl -sk \
182+
-H "Content-Type: application/json" \
183+
-H "x-api-key: $API_KEY" \
184+
"$GATEWAY/llm/sim-chat/v1/chat/completions" \
185+
-d '{
186+
"model": "sim-chat",
187+
"messages": [{"role": "user", "content": "hello"}],
188+
"max_tokens": 50
189+
}'
190+
```
191+
192+
### Chat Completions (body-based routing — BBR)
193+
194+
```bash
195+
curl -sk \
196+
-H "Content-Type: application/json" \
197+
-H "x-api-key: $API_KEY" \
198+
"$GATEWAY/v1/chat/completions" \
199+
-d '{
200+
"model": "sim-chat",
201+
"messages": [{"role": "user", "content": "hello"}],
202+
"max_tokens": 50
203+
}'
204+
```
205+
206+
### Messages (body-based routing — BBR)
207+
208+
```bash
209+
curl -sk \
210+
-H "Content-Type: application/json" \
211+
-H "x-api-key: $API_KEY" \
212+
"$GATEWAY/v1/messages" \
213+
-d '{
214+
"model": "sim-messages",
215+
"messages": [{"role": "user", "content": "hello"}],
216+
"max_tokens": 50
217+
}'
218+
```
219+
220+
### Streaming Chat Completions
221+
222+
```bash
223+
curl -sk -N \
224+
-H "Content-Type: application/json" \
225+
-H "x-api-key: $API_KEY" \
226+
"$GATEWAY/v1/chat/completions" \
227+
-d '{
228+
"model": "sim-chat",
229+
"messages": [{"role": "user", "content": "hello"}],
230+
"max_tokens": 50,
231+
"stream": true
232+
}'
233+
```
234+
235+
### Wrong model (should be rejected — validates BBR is active)
236+
237+
```bash
238+
curl -sk \
239+
-H "Content-Type: application/json" \
240+
-H "x-api-key: $API_KEY" \
241+
"$GATEWAY/v1/chat/completions" \
242+
-d '{
243+
"model": "nonexistent-model",
244+
"messages": [{"role": "user", "content": "hello"}],
245+
"max_tokens": 50
246+
}'
247+
```
248+
249+
## Dogfood Cluster (sandbox311)
250+
251+
- Console: `https://console-openshift-console.apps.ocp.nrt9w.sandbox311.opentlc.com`
252+
- Gateway: `https://maas.apps.ocp.nrt9w.sandbox311.opentlc.com`
253+
- Models namespace: `llm`
254+
- Simulator IP: `3-132-132-211.sslip.io`

0 commit comments

Comments
 (0)