Skip to content
Open
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
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,38 @@ Browse and discover AI models on the [OpenGradient Model Hub](https://hub.opengr

- Visit our [documentation](https://docs.opengradient.ai/) for detailed guides
- Join our [community](https://discord.gg/axammqTRDz) for support and discussions

## End-to-End Example

Here is a complete end-to-end example showing how a developer can go from zero to making an inference call:

```python
import os
from opengradient import OpenGradientClient

# Initialize the client
client = OpenGradientClient(
api_key=os.environ["OPENGRADIENT_API_KEY"],
tee_url=os.environ.get("OPENGRADIENT_TEE_URL", "https://tee.opengradient.ai"),
)

# List available models
models = client.list_models()
print(f"Available models: {[m.id for m in models]}")

if models:
model_id = models[0].id
# Prepare input data
input_data = {"text": "Hello, world!"}
try:
result = client.inference.predict(model_id, input_data)
print(f"Inference result: {result}")
except Exception as e:
print(f"Inference failed: {e}")
```

This example demonstrates:
1. Client initialization with API key
2. Listing available models
3. Making an inference call with error handling
4. Environment-based configuration