Add getting-started module: ChatClient fluent API, system/user prompts, streaming, and provider switching via spring.ai.model.chat
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# A real HTTP round trip to OpenAI (not scripted) -- captured manually, not by run-all.sh
|
||||
|
||||
This one is not reproducible by scripts/run-all.sh: it needs a live network path to
|
||||
api.openai.com, which the automated test suite deliberately does not depend on (see
|
||||
ChatClientEndpointsTest, which uses FakeChatModel instead). It is included because it is the
|
||||
one exhibit in this module that touches a real provider, and it proves the request pipeline
|
||||
-- ChatClient, the OpenAiChatModel bean spring.ai.model.chat=openai selected, and the OpenAI
|
||||
Java SDK underneath it -- is wired correctly all the way to OpenAI's own server, not just to
|
||||
a stub.
|
||||
|
||||
Command (full application, spring-boot:run, a syntactically valid but fake key):
|
||||
|
||||
$ export OPENAI_API_KEY=sk-test-placeholder-not-a-real-key
|
||||
$ curl 'http://localhost:8080/api/chat?message=hi'
|
||||
|
||||
Response: HTTP 500, body in 05-real-openai-401-response-body.txt
|
||||
|
||||
Application log root cause (grepped from the running process's stdout):
|
||||
|
||||
com.openai.errors.UnauthorizedException: 401: Incorrect API key provided: sk-test-**********************-key. You can find your API key at https://platform.openai.com/account/api-keys.
|
||||
|
||||
That 401 comes from OpenAI's own server, not from Spring AI or from this sandbox -- OpenAI
|
||||
validated the key format, rejected it, and said so in its own error class
|
||||
(com.openai.errors.UnauthorizedException). A malformed request, a wrong base URL, or a client
|
||||
that never left the JVM would not look like this. Swap in a real key and this becomes a real
|
||||
reply.
|
||||
Reference in New Issue
Block a user