Update Agent Settings Using CustomGPT.ai’s RAG API’s Python SDK – A Comprehensive Guide

Author Image

Written by: Priyansh Khodiyar

Update Agent Settings Using CustomGPT.ai’s RAG API’s Python SDK

Need to tweak your chatbot’s default prompt, language, or example questions without touching the dashboard? This tutorial shows you how to fetch and update agent settings via the CustomGPTs RAG APIs Python SDK implementation.

We’ll move through these steps:

  1. Install & authenticate the SDK
  2. Retrieve the current settings for context
  3. Build an update payload
  4. Apply the changes with one API call
  5. Verify everything updated correctly

If you’re brand‑new, first sign up and read Getting Started with CustomGPT.ai.
For complete code, see the GitHub Cookbook notebook.
Full reference: API docs.

Prerequisites

RequirementDetails
API KeyNeeds “settings‑update” scope. Generate under Settings → API Tokens.
Project IDThe agent whose settings you’ll update.
Python 3 + customgpt‑clientInstall with pip install customgpt-client.
Basic Python SkillsComfortable running scripts and working with dictionaries.

Everything ready? Let’s jump in.

1 – Authenticate the SDK

First, install (if you haven’t) and authenticate the SDK so all calls carry your token.

# Install the SDK (run once per environment)

!pip install customgpt-client

# Import the SDK interface

from customgpt_client import CustomGPT

CustomGPT.api_key = "YOUR_API_TOKEN"      # ← Replace with your real token

Why this matters
Setting api_key globally means every subsequent function call is automatically authorized—no manual headers required.

Get API keys

To get your API key, there are two ways:

Method 1 – Via Agent

  1. Agent > All Agents.
  2. Select your agent and go to deploy, click on the API key section and create an API. 

Method 2 – Via Profile section.

  1. Go to profile (top right corner of your screen)
  2. Click on My Profile
  3. You will see the screen something like this (below screenshot). Here you can click on “Create API key”, give it a name and copy the key.
Create API

Please save this secret key somewhere safe and accessible. For security reasons, You won’t be able to view it again through your CustomGPT.ai account. If you lose this secret key, you’ll need to generate a new one.

Now that we’re authenticated, let’s take a snapshot of the current settings.

2 – Retrieve Current Settings

Fetching existing values lets you verify what’s already configured and decide what to change.

# Pull the current settings for reference

current_settings = CustomGPT.ProjectSettings.get(

    project_id="YOUR_PROJECT_ID"          # ← your agent’s ID

)

print("Current Settings:\n", current_settings.parsed.data)

What you’ll see

Typical fields include:

FieldExample
default_prompt“Ask me anything …”
chatbot_msg_lang“en”
example_questions[“What do you do?”, …]
response_source“default”

Knowing these values helps you craft an accurate update payload.

With the baseline captured, let’s prepare new settings.

3 – Define the Update Payload

Only include keys you want to change; all others stay as‑is.

# Build a dictionary containing only the fields you wish to modify

new_settings = {

    "default_prompt": "Hello! Ask me anything about our docs.",  # New system prompt

    "chatbot_msg_lang": "en",                                    # Language code

    "example_questions": [                                       # Suggested starter prompts

        "How do I integrate the API?",

        "Where can I find code examples?",

        "What are the rate limits?"

    ],

    "allow_user_feedback": True                                  # Toggle feedback widget

}

Tip
If you don’t want to touch a field, just omit it—ProjectSettings.update leaves unspecified fields unchanged.

Payload ready? Let’s push the update.

4 – Apply the Settings Update

We pass our dictionary as keyword arguments so each key maps to an API parameter.

update_resp = CustomGPT.ProjectSettings.update(

    project_id="YOUR_PROJECT_ID",   # Target project

    **new_settings                  # Unpack the dict into kwargs

)

print("Update Status:", update_resp.status)  # Should print "success"

Under the hood
ProjectSettings.update sends a PATCH/PUT to /projects/{id}/settings with only the fields you provided.

A “success” response means the backend accepted your changes—let’s double‑check.

5 – Verify the Changes

Pull the settings again and confirm they match your payload.

verified_settings = CustomGPT.ProjectSettings.get(

    project_id="YOUR_PROJECT_ID"

)

print("Verified Settings:\n", verified_settings.parsed.data)

Quick sanity check

  • Does default_prompt show the new text?
  • Are the example_questions updated?
  • Is chatbot_msg_lang now “en” (or whichever code you set)?

If something didn’t stick, re‑examine your payload for typos.

With updates confirmed, you’ve successfully re‑configured your chatbot on the fly!

Troubleshooting & FAQs

Common Issues

ProblemSolution
Invalid API KeyEnsure CustomGPT.api_key is correct and unexpired.
Missing permissionToken needs “settings‑update” scope.
Unhandled fieldSending a key the API doesn’t recognize returns a validation error—remove it.
Boolean fields ignoredUse proper Python booleans (True / False), not strings.

Frequently Asked Questions

Update only one field?

Absolutely—send just that key in new_settings.

Clear example questions?

Provide an empty list: “example_questions”: [ ].

Effect on active chats?

Ongoing sessions keep their original default_prompt; new sessions use the updated one.

Read‑only fields?

Timestamps like created_at are immutable.

Automate in CI/CD?

Yes—place these SDK calls in your deployment scripts or GitHub Actions.

Related Resources

    Conclusion

    In this tutorial you:

    1. Authenticated the CustomGPT Python SDK
    2. Fetched your project’s current settings
    3. Crafted a focused update payload
    4. Applied the changes in one line of code
    5. Verified the new configuration

    With this approach, you can programmatically fine‑tune prompt language, sample questions, and feature toggles—perfect for CI/CD pipelines or large‑scale bot fleets.

    Happy coding, and keep refining those chatbots!

    Build a Custom GPT for your business, in minutes.

    Deliver exceptional customer experiences and maximize employee efficiency with custom AI agents.

    Trusted by thousands of organizations worldwide

    Related posts

    Leave a reply

    Your email address will not be published. Required fields are marked *

    *

    3x productivity.
    Cut costs in half.

    Launch a custom AI agent in minutes.

    Instantly access all your data.
    Automate customer service.
    Streamline employee training.
    Accelerate research.
    Gain customer insights.

    Try 100% free. Cancel anytime.