Skip to content

Commit dc63a6a

Browse files
committed
Fixing the partner URL and adding readme for examples.
1 parent 8c01b98 commit dc63a6a

7 files changed

Lines changed: 111 additions & 12 deletions

File tree

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,8 @@ client = OpenAI(
111111
)
112112
```
113113

114-
## Running the Examples
115-
116-
1. Update `examples/agenthub/common.py` and/or `examples/partner/openai/common.py` with your `COMPARTMENT_ID`, `PROJECT_OCID`, and set the correct `REGION`.
117-
2. Set the `OCI_GENAI_API_KEY` environment variable when an example uses API key authentication.
118-
3. Install optional dev dependencies: `pip install -e '.[dev]'`.
119-
120-
Run an example either by calling its `main()` method or from the command line.
114+
## Examples
115+
Demo code and instructions on how to run them, for both agenthub and partner usecases can be found in ```examples``` folder.
121116

122117
## Contributing
123118

examples/agenthub/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# AgentHub Examples
2+
3+
This folder contains examples for OCI Generative AI AgentHub APIs using the OpenAI Python SDK.
4+
5+
## Prerequisites
6+
7+
1. Install dependencies:
8+
9+
```bash
10+
pip install -e '.[dev]'
11+
```
12+
13+
2. Configure shared values in `examples/agenthub/common.py`:
14+
- `PROFILE_NAME`
15+
- `COMPARTMENT_ID`
16+
- `PROJECT_OCID`
17+
- `REGION`
18+
19+
3. (Optional) You can override project at runtime:
20+
21+
```bash
22+
export OCI_GENAI_PROJECT_ID=<your_project_ocid>
23+
```
24+
25+
4. If running API-key based examples, set:
26+
27+
```bash
28+
export OPENAI_API_KEY=<your_oci_genai_api_key>
29+
```
30+
31+
## How to run
32+
33+
From repository root, run any example module with `python -m`.
34+
35+
Quickstarts:
36+
37+
```bash
38+
python -m examples.agenthub.quickstart_responses_create_oci_iam
39+
python -m examples.agenthub.quickstart_responses_create_api_key
40+
```
41+
42+
Responses API examples:
43+
44+
```bash
45+
python -m examples.agenthub.responses.create_response
46+
python -m examples.agenthub.responses.streaming_text_delta
47+
python -m examples.agenthub.responses.structured_output
48+
python -m examples.agenthub.responses.use_gpt_model
49+
python -m examples.agenthub.responses.use_google_gemini_model
50+
```
51+
52+
Tools examples:
53+
54+
```bash
55+
python -m examples.agenthub.tools.function_calling
56+
python -m examples.agenthub.tools.web_search
57+
python -m examples.agenthub.tools.code_interpreter
58+
```
59+
60+
Other categories follow the same pattern:
61+
62+
```bash
63+
python -m examples.agenthub.agents.basic_agents_example
64+
python -m examples.agenthub.multiturn.responses_chaining
65+
python -m examples.agenthub.memory.long_term_memory
66+
python -m examples.agenthub.mcp.create_responses_mcp
67+
python -m examples.agenthub.vector_stores.vector_stores_crud
68+
python -m examples.agenthub.files.files_crud
69+
python -m examples.agenthub.function.create_responses_fc
70+
```
71+
72+
## Notes
73+
74+
- Most examples use IAM signing through `oci-genai-auth`.
75+
- AgentHub examples use OpenAI-compatible `/openai/v1` endpoints and require a project OCID.

examples/agenthub/agents/basic_agents_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ async def main():
1717
print(result.final_output)
1818

1919
if __name__ == "__main__":
20-
asyncio.run(main())
20+
asyncio.run(main())

examples/partner/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Partner Examples
2+
3+
This folder contains partner API examples using the OpenAI Python SDK.
4+
5+
## Prerequisites
6+
7+
1. Install dependencies:
8+
9+
```bash
10+
pip install -e '.[dev]'
11+
```
12+
13+
2. Configure shared values in `examples/partner/common.py`:
14+
- `PROFILE_NAME`
15+
- `COMPARTMENT_ID`
16+
- `REGION`
17+
18+
## How to run
19+
20+
From repository root:
21+
22+
```bash
23+
python -m examples.partner.openai.quickstart_openai_chat_completions
24+
```
25+
26+
## Notes
27+
28+
- Partner endpoints use pass-through mode and require the `opc-compartment-id` header.
29+
- These examples use IAM signing through `oci-genai-auth`.

examples/partner/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2026 Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
33

4-
"""Partner (pass-through) example clients and configuration."""
4+
"""Partner example clients and configuration."""
55

66
from __future__ import annotations
77

@@ -14,7 +14,7 @@
1414
COMPARTMENT_ID = "<<ENTER_COMPARTMENT_ID>>"
1515
REGION = "us-chicago-1"
1616

17-
PARTNER_OPENAI_BASE_URL = f"https://inference.generativeai.{REGION}.oci.oraclecloud.com/v1"
17+
PARTNER_OPENAI_BASE_URL = f"https://inference.generativeai.{REGION}.oci.oraclecloud.com/20231130/actions/v1"
1818

1919

2020
def build_openai_client() -> OpenAI:

examples/partner/openai/basic_chat_completion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2026 Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
33

4-
"""Demonstrates a basic chat completion request for the Partner (pass-through) endpoint."""
4+
"""Demonstrates a basic chat completion request for the Partner endpoint."""
55

66
from rich import print
77

examples/partner/openai/tool_call_chat_completion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2026 Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
33

4-
"""Demonstrates tool calling with chat completions for the Partner (pass-through) endpoint."""
4+
"""Demonstrates tool calling with chat completions for the Partner endpoint."""
55

66
import json
77
from typing import Dict

0 commit comments

Comments
 (0)