Skip to content

docs: Add sample code - #91

Merged
mwien merged 13 commits into
mainfrom
add-sample-code
Sep 3, 2026
Merged

docs: Add sample code#91
mwien merged 13 commits into
mainfrom
add-sample-code

Conversation

@mwien

@mwien mwien commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Closes SAP/ai-sdk-python-backlog#5.
Follow-up for adding more samples SAP/ai-sdk-python-backlog#27.

This PR adds example code that showcases usage of the SDK by exposing HTTP endpoints via a FastAPI application. Similar sample code exists for the other two AI SDKs.

This is a draft PR. The architecture/integration of the sample code may be up to discussion and more features should be added.

Currently, examples are included for the following services:

  • configurations/deployments via the core package
  • native clients (OpenAI/Google/Amazon)
  • orchestration

The following additions are planned:

  • LangChain
  • Grounding
  • Prompt Registry
  • RPT Models

Open things/questions up for discussion:

  • Should the sample_code package be part of the root workspace? This is how it is currently proposed. It would be useful for using it for end-to-end smoke tests.
  • I had to add a pyrightconfig.json to the sample code repo for Pyright to find the base, core and gen packages. Maybe there are better solutions.
  • Currently, each example is completely self-contained (to make it easy to understand and try out for beginners). However, therefore a new OrchestrationService client is created for each orchestration request. How should the correct cleanup look like (for example with regard to the close_http_connection method, which only closes the sync client)?
  • There are some minor type errors from the type checker that one could look into.

@mwien
mwien requested a review from ZhongpinWang August 25, 2026 13:48
Comment thread sample-code/src/sample_code/__init__.py Outdated
Comment thread sample-code/Makefile Outdated
@mwien

mwien commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Another thing to note: I'm currently using a .env file for config that's supposed to lie in the sample-code folder. We could also use a .env file in the repo root...

@ZhongpinWang

Copy link
Copy Markdown
Contributor

Another thing to note: I'm currently using a .env file for config that's supposed to lie in the sample-code folder. We could also use a .env file in the repo root...

Probably I missed it since I am a python sdk newbie. But why is there a .env already at repo root? In JS and Java, we just put .env in sample code and smoke test packages only as these are the only apps that need the credential?

@mwien

mwien commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

I don't know of any current .env at the repo root but maybe I missed that. This was just a question where the .env file should lie if we recommend using that for auth in the sample code.

@ZhongpinWang

Copy link
Copy Markdown
Contributor

I don't know of any current .env at the repo root but maybe I missed that. This was just a question where the .env file should lie if we recommend using that for auth in the sample code.

Java and JS stores the .env inside the sample code and smoke test applications. It also makes sense to me as rest of the project does not need this?

@ZhongpinWang ZhongpinWang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general look good to me. @mwien Anything left in your mind before we can merge it? Should we turn the PR from draft to review ready?

@mwien
mwien marked this pull request as ready for review September 3, 2026 08:09
@mwien
mwien requested a review from alpkom as a code owner September 3, 2026 08:09
Comment thread sample-code/sample_code/orchestration.py Outdated
@mwien
mwien requested a review from ZhongpinWang September 3, 2026 08:22
Comment thread sample-code/sample_code/google.py Outdated
Comment thread sample-code/sample_code/google.py Outdated
Comment thread sample-code/sample_code/orchestration.py
@mwien
mwien requested a review from ZhongpinWang September 3, 2026 09:55

@ZhongpinWang ZhongpinWang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, further sample code can be added later.

@mwien
mwien merged commit ad40f61 into main Sep 3, 2026
15 checks passed
@mwien
mwien deleted the add-sample-code branch September 3, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants