Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,8 @@ client = OpenAI(
)
```

## Running the Examples

1. Update `examples/agenthub/common.py` and/or `examples/partner/openai/common.py` with your `COMPARTMENT_ID`, `PROJECT_OCID`, and set the correct `REGION`.
2. Set the `OCI_GENAI_API_KEY` environment variable when an example uses API key authentication.
3. Install optional dev dependencies: `pip install -e '.[dev]'`.

Run an example either by calling its `main()` method or from the command line.
## Examples
Demo code and instructions on how to run them, for both agenthub and partner usecases can be found in ```examples``` folder.

## Contributing

Expand Down
75 changes: 75 additions & 0 deletions examples/agenthub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# AgentHub Examples

This folder contains examples for OCI Generative AI AgentHub APIs using the OpenAI Python SDK.

## Prerequisites

1. Install dependencies:

```bash
pip install -e '.[dev]'
```

2. Configure shared values in `examples/agenthub/common.py`:
- `PROFILE_NAME`
- `COMPARTMENT_ID`
- `PROJECT_OCID`
- `REGION`

3. (Optional) You can override project at runtime:

```bash
export OCI_GENAI_PROJECT_ID=<your_project_ocid>
```

4. If running API-key based examples, set:

```bash
export OPENAI_API_KEY=<your_oci_genai_api_key>
```

## How to run

From repository root, run any example module with `python -m`.

Quickstarts:

```bash
python -m examples.agenthub.quickstart_responses_create_oci_iam
python -m examples.agenthub.quickstart_responses_create_api_key
```

Responses API examples:

```bash
python -m examples.agenthub.responses.create_response
python -m examples.agenthub.responses.streaming_text_delta
python -m examples.agenthub.responses.structured_output
python -m examples.agenthub.responses.use_gpt_model
python -m examples.agenthub.responses.use_google_gemini_model
```

Tools examples:

```bash
python -m examples.agenthub.tools.function_calling
python -m examples.agenthub.tools.web_search
python -m examples.agenthub.tools.code_interpreter
```

Other categories follow the same pattern:

```bash
python -m examples.agenthub.agents.basic_agents_example
python -m examples.agenthub.multiturn.responses_chaining
python -m examples.agenthub.memory.long_term_memory
python -m examples.agenthub.mcp.create_responses_mcp
python -m examples.agenthub.vector_stores.vector_stores_crud
python -m examples.agenthub.files.files_crud
python -m examples.agenthub.function.create_responses_fc
```

## Notes

- Most examples use IAM signing through `oci-genai-auth`.
- AgentHub examples use OpenAI-compatible `/openai/v1` endpoints and require a project OCID.
2 changes: 1 addition & 1 deletion examples/agenthub/agents/basic_agents_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ async def main():
print(result.final_output)

if __name__ == "__main__":
asyncio.run(main())
asyncio.run(main())
29 changes: 29 additions & 0 deletions examples/partner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Partner Examples

This folder contains partner API examples using the OpenAI Python SDK.

## Prerequisites

1. Install dependencies:

```bash
pip install -e '.[dev]'
```

2. Configure shared values in `examples/partner/common.py`:
- `PROFILE_NAME`
- `COMPARTMENT_ID`
- `REGION`

## How to run

From repository root:

```bash
python -m examples.partner.openai.quickstart_openai_chat_completions
```

## Notes

- Partner endpoints use pass-through mode and require the `opc-compartment-id` header.
- These examples use IAM signing through `oci-genai-auth`.
4 changes: 2 additions & 2 deletions examples/partner/common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2026 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

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

from __future__ import annotations

Expand All @@ -14,7 +14,7 @@
COMPARTMENT_ID = "<<ENTER_COMPARTMENT_ID>>"
REGION = "us-chicago-1"

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


def build_openai_client() -> OpenAI:
Expand Down
2 changes: 1 addition & 1 deletion examples/partner/openai/basic_chat_completion.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2026 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

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

from rich import print

Expand Down
2 changes: 1 addition & 1 deletion examples/partner/openai/tool_call_chat_completion.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2026 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

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

import json
from typing import Dict
Expand Down
Loading