> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simplismart.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Inference

This guide will walk you through making your first API call to Simplismart's pre-deployed models. Before starting, ensure you have [signed up](/signup) for a Simplismart account.

## Prerequisites

* A Simplismart account
* Basic Python knowledge
* Python 3.8+ installed on your system

## Step-by-Step Guide

<Steps>
  <Step title="Access the Playground">
    1. Log in to your [Simplismart account](https://app.simplismart.a)
    2. From the left sidebar, click on **Playground**
    3. In the model dropdown, select [Gemma 4 31B Instruct](https://app.simplismart.ai/playground?model_id=2efc00b2-4a9a-49a9-ba94-d852e0e7637c). (For example purposes, Gemma 4 31B is considered here. Any other LLM can be used as well.)
    4. You'll see an interactive chat interface where you can test the model directly

           <img src="https://mintcdn.com/simplismart-3f10d72e/PFD4pd35bs-vm7NW/images/get-started/inference/gemma-4-playground.png?fit=max&auto=format&n=PFD4pd35bs-vm7NW&q=85&s=c8e874640839aa635dd663707054c3e3" alt="Playground interface with model selection" width="3002" height="1718" data-path="images/get-started/inference/gemma-4-playground.png" />
  </Step>

  <Step title="Get API Details">
    1. In the Playground, click on **Get API details** in the left sidebar
    2. You'll be redirected to a page with ready-to-use code snippets
    3. Note that both Python (OpenAI client) and cURL examples are provided
    4. Copy the provided code snippet or use the given below

    <Tip>
      The API is compatible with any OpenAI-compliant client library, not just the official Python SDK.
    </Tip>
  </Step>

  <Step title="Create Your Python Script">
    Create a new file named `inference.py` with the following code:

    ```python theme={null}
    # inference.py
    from openai import OpenAI

    # Replace with your actual API key from Settings > API Keys
    simplismart_api_key = "SIMPLISMART_API_KEY"    

    # Replace with your endpoint for the Gemma-3-1B model from the Model details page 
    simplismart_base_url = "https://api.simplismart.live"

    try:
        # Initialize the OpenAI client with Simplismart endpoint
        client = OpenAI(
            api_key=simplismart_api_key,
            base_url=simplismart_base_url,        
        )
        
        # Define model and prompt
        MODEL_NAME = "google/gemma-4-31B-it"
        PROMPT = "What is quantization in GenAI models?"    

        print(f"User: {PROMPT}\n")
        print("AI Assistant: ", end="", flush=True)

        # Create a streaming completion request
        stream = client.chat.completions.create(
            model=MODEL_NAME,
            messages=[
                {
                    "role": "system",
                    "content": "You are a helpful AI assistant."
                },
                {
                    "role": "user", 
                    "content": PROMPT
                }
            ],
            max_tokens=512,  # Response length limit
            stream=True,     # Enable streaming for faster first token
        )

        # Process the streamed response
        for chunk in stream:        
            text_delta = chunk.choices[0].delta.content
            if text_delta:            
                print(text_delta, end="", flush=True)
        print()  # Add newline after response

    except Exception as e:    
        print(f"An unexpected error occurred: {e}")
    ```

    <Note>
      Remember to replace `"YOUR_API_KEY"` and `YOUR_MODEL_ENDPOINT` with the actual API key and model endpoint you generated in the previous steps.
    </Note>
  </Step>

  <Step title="Generate an API Key" href="../model-suite/settings/api-keys">
    1. Navigate to **Settings > API Keys** from the main sidebar
    2. Click **Generate New Key**
    3. Provide a descriptive name for your key (must be unique)
    4. Set an appropriate expiration date
    5. Copy the generated API key (you won't be able to see it again)

           <img src="https://mintcdn.com/simplismart-3f10d72e/UUGggl0C02jion4f/images/settings/api-keys/generate-api-key.png?fit=max&auto=format&n=UUGggl0C02jion4f&q=85&s=833a595c7fce56e235716be0da49a70c" alt="Settings" width="3022" height="1721" data-path="images/settings/api-keys/generate-api-key.png" />

    <Warning>
      Keep your API key secure and never expose it in client-side code or public repositories.
    </Warning>
  </Step>

  <Step title="Run Your Script">
    1. Install the OpenAI Python client if you haven't already:

    ```shell theme={null}
    pip install openai
    ```

    2. Run your script:

    ```shell theme={null}
    python inference.py
    ```

    3. You should see the model's response to your query streaming in your terminal!

    <Check>
      Congratulations! 🎉 You've successfully made your first API call to a Simplismart model.
    </Check>
  </Step>
</Steps>

## Understanding Shared vs. Dedicated Endpoints

In this quickstart, you used a **shared endpoint** - a pre-deployed model that's available to all Simplismart users. While convenient for testing and development, shared endpoints have some limitations:

<CardGroup cols="2">
  <Card title="Shared Endpoints" icon="share-nodes" href="../inference/shared-endpoint">
    * Quick to get started and no deployment required
    * Easy switching between different models
    * Pay-as-you-go pricing
    * Limited customization options
  </Card>

  <Card title="Dedicated Endpoints" icon="server" href="../inference/dedicated-endpoint">
    * Private to your organisation and optimised for your needs
    * Option to choose from a wide range of customisation
    * Deploy and scale your proprietary model hassle-free
    * Better control over latency, throughput, and costs
  </Card>
</CardGroup>

## Next Steps

Ready to take your AI implementation further? Try these next steps:

* [Deploy your own dedicated model](/quickstart/deploy) for better performance and customization

{ /* - [Fine-tune a model](/quickstart/finetuning) on your own data for improved accuracy */ }

* [Explore the API reference](/api-reference/introduction) for advanced integration options
