From a2bebd5dbe83d5994ba05d6958be0cb7af567d40 Mon Sep 17 00:00:00 2001 From: Gtax2006 Date: Thu, 28 May 2026 01:08:09 +0800 Subject: [PATCH] docs: add end-to-end example for first-time developers (#245) --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 551b552..b8044ed 100644 --- a/README.md +++ b/README.md @@ -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