For development teams and DevOps architects, confining an AI agent to a personal IDE sidebar is a severe limitation. When your team spends weeks in Code GPT Studio curating proprietary codebase graphs, importing architectural decision records (ADRs), and fine-tuning prompt rules, that intelligence belongs in your enterprise ecosystem—embedded inside internal developer portals, CI/CD pull request review pipelines, and operational ChatOps bots.
The Code GPT Plus API and its official Python SDK (judini) provide the backend bridge to do exactly that. This guide details how software engineers authenticate with the Code GPT Plus API, connect programmatically to custom Studio agents via their unique Agent ID, stream real-time code recommendations, and implement resilient integration patterns for internal tools.
The 365Finds Institutional Judgment
At 365Finds, our evaluation of Code GPT Plus API for backend engineering teams centers on one core advantage: it abstracts away the entire Retrieval-Augmented Generation (RAG) and Code Graph indexing infrastructure.
Instead of maintaining a custom vector database, parsing abstract syntax trees (ASTs), chunking git repositories, and orchestrating multi-model failovers, Code GPT Studio manages the entire knowledge layer. Your backend applications consume this specialized knowledge through a clean, unified API endpoint.
+-------------------------------------------------------------+
| Code GPT Studio |
| +---------------------+ +-------------------------------+ |
| | Git Code Graph (AST)| | Internal ADRs & Documentation | |
| +---------------------+ +-------------------------------+ |
| | | |
| +--------------+---------------+ |
| v |
| Custom AI Agent (Agent ID) |
| (Claude 3.5 / GPT-4o / Gemini) |
+---------------------------+---------------------------------+
|
Code GPT Plus API (REST / Python SDK `judini`)
|
+------------------------+------------------------+
v v v
Internal Developer CI/CD Pipeline DevOps ChatOps
Portal (Backstage) (PR Auto-Review) (Slack / Bot)
Where 365Finds Recommends Code GPT Plus API:
- Teams seeking to enforce unified coding standards and domain knowledge across both IDEs and automated CI pipelines.
- Organizations that want model independence (switching between Claude 3.5 Sonnet, GPT-4o, and DeepSeek) without rewriting internal tool logic.
- Engineering backends that require repo-level contextual understanding without the operational overhead of a self-hosted code graph pipeline.
Important Tradeoffs to Consider:
- Pricing Structure: The Code GPT API Plan charges $20 per 1,000 interactions (with a $50 monthly minimum baseline) plus model token consumption. High-frequency, sub-second transactional scripts should evaluate whether batching interactions is necessary.
- Single Graph Constraint: Each Studio agent binds to one repository graph at a time. If an internal tool spans a distributed microservices architecture, you must orchestrate multiple Agent IDs or unify submodules.
Phase 1: Provisioning Studio Agents and Credentials
Before writing backend code, you must retrieve three configuration parameters from the Code GPT platform: the API Key, the Organization ID, and the Agent ID.
1. Retrieve the Organization ID and Secret API Key
- Log in to Code GPT Studio.
- Navigate to the API Keys Management Page.
- Copy your Organization ID (
CODEGPT_ORG_ID). This identifier isolates your agent configurations and usage data. - Click Create New Token / API Key, assign a descriptive name (e.g.,
internal-tools-pipeline), and store the generated secret key (CODEGPT_API_KEY) in your secure credential store.
2. Obtain Your Custom Agent ID
- In the left navigation of Code GPT Studio, select My Agents under the Agents tab.
- Click on the custom agent trained on your architecture standards or code graph.
- Access the agent's settings panel. The Agent ID is a unique UUID (for example,
46095c69-7b74-4d66-b46a-0b97e7bbe82b). - Ensure the agent has its Agent Knowledge properly attached (Graphs for Git repos, Files for documentation) and that the status indicates training is complete.
3. Configure Local Environment Variables
Create a .env file in your project root:
CODEGPT_API_KEY="sk-codegpt-xxxxxxxxxxxxxxxxxxxxxxxx"
CODEGPT_ORG_ID="org-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
CODEGPT_AGENT_ID="agent-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
Phase 2: Connecting via Python SDK (judini)
Code GPT publishes its official Python client library under the package name judini on PyPI. It provides synchronous and asynchronous bindings to interact with Code GPT Plus agents.
1. Installation
Install the SDK and supporting libraries:
pip install judini python-dotenv requests
2. Basic Synchronous Chat Completion
To query your custom Studio agent and receive a complete response:
import os
from dotenv import load_dotenv
from judini import CodeGPTPlus
load_dotenv()
# Initialize the client with your credentials
client = CodeGPTPlus(
api_key=os.getenv("CODEGPT_API_KEY"),
org_id=os.getenv("CODEGPT_ORG_ID")
)
agent_id = os.getenv("CODEGPT_AGENT_ID")
messages = [
{
"role": "user",
"content": "Review this function for concurrency issues:\n\n"
"def process_order(order_id):\n"
" balance = get_balance()\n"
" if balance >= 100:\n"
" deduct(100)\n"
" record_transaction(order_id)"
}
]
response = client.chat_completion(
agent_id=agent_id,
messages=messages
)
print(response)
3. Streaming Code Recommendations in Real Time
For lengthy code generation or refactoring tasks, streaming chunks prevents HTTP gateway timeouts (such as 504 Gateway Timeout) and improves the end-user experience:
import os
from dotenv import load_dotenv
from judini import CodeGPTPlus
load_dotenv()
client = CodeGPTPlus(
api_key=os.getenv("CODEGPT_API_KEY"),
org_id=os.getenv("CODEGPT_ORG_ID")
)
agent_id = os.getenv("CODEGPT_AGENT_ID")
prompt_payload = [
{
"role": "user",
"content": "Refactor this legacy data access module into an asynchronous Repository pattern."
}
]
print("--- Streaming response from Code GPT Studio Agent ---")
for chunk in client.chat_completion(agent_id=agent_id, messages=prompt_payload, stream=True):
print(chunk, end="", flush=True)
print("\n--- End of response ---")
Phase 3: Direct REST API Specification
If your stack avoids Python or relies on direct HTTP invocations (e.g., inside curl scripts, Golang backends, or API gateways), call the REST endpoint directly.
- HTTP Method:
POST - Endpoint URL:
https://api.codegpt.co/api/v1/chat/completions - Required Headers:
Authorization: Bearer <CODEGPT_API_KEY>CodeGPT-Org-Id: <CODEGPT_ORG_ID>Content-Type: application/json
cURL Request Example:
curl -X POST "https://api.codegpt.co/api/v1/chat/completions" \
-H "Authorization: Bearer $CODEGPT_API_KEY" \
-H "CodeGPT-Org-Id: $CODEGPT_ORG_ID" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "'"$CODEGPT_AGENT_ID"'",
"messages": [
{
"role": "user",
"content": "Verify if our authentication interceptor conforms to ADR-014."
}
],
"stream": false
}'
Node.js SDK Alternative:
For engineering teams operating Node.js or TypeScript microservices, the matching judini package is available on npm:
import { CodeGPTPlus } from 'judini';
const codegpt = new CodeGPTPlus({
apiKey: process.env.CODEGPT_API_KEY!,
orgId: process.env.CODEGPT_ORG_ID!
});
async function runReview() {
const result = await codegpt.chatCompletion(
{
agentId: process.env.CODEGPT_AGENT_ID!,
messages: [{ role: 'user', content: 'Check API schema compliance.' }]
},
(chunk: string) => {
process.stdout.write(chunk);
}
);
}
Phase 4: Production Integration Patterns
Pattern A: FastAPI Proxy for Internal Developer Portals
Never expose your CODEGPT_API_KEY to client-side browsers. The standard enterprise architecture uses a lightweight backend service that authenticates corporate users and proxies streaming chunks via Server-Sent Events (SSE).
import os
from fastapi import FastAPI, HTTPException, Depends
from fastapi.responses import StreamingResponse
from pydantic import BaseModel
from judini import CodeGPTPlus
app = FastAPI(title="Internal DevBot Service")
codegpt_client = CodeGPTPlus(
api_key=os.getenv("CODEGPT_API_KEY"),
org_id=os.getenv("CODEGPT_ORG_ID")
)
AGENT_ID = os.getenv("CODEGPT_AGENT_ID")
class CodeReviewRequest(BaseModel):
code_snippet: str
target_context: str = "general"
def event_stream_generator(prompt: str):
messages = [
{"role": "system", "content": "You are our company internal code reviewer."},
{"role": "user", "content": prompt}
]
try:
for chunk in codegpt_client.chat_completion(agent_id=AGENT_ID, messages=messages, stream=True):
if chunk:
yield f"data: {chunk}\n\n"
except Exception as exc:
yield f"data: [ERROR]: {str(exc)}\n\n"
@app.post("/api/v1/review/stream")
async def review_code_stream(request: CodeReviewRequest):
if not request.code_snippet.strip():
raise HTTPException(status_code=400, detail="Code snippet cannot be empty.")
prompt = f"Context: {request.target_context}\nReview this code:\n{request.code_snippet}"
return StreamingResponse(
event_stream_generator(prompt),
media_type="text/event-stream"
)
Pattern B: CI/CD Pipeline Automated PR Code Reviewer
You can invoke the Studio agent during automated GitHub Actions or GitLab CI runs to evaluate pull request diffs against your team's trained architecture rules.
import os
import subprocess
import requests
from judini import CodeGPTPlus
def get_git_diff() -> str:
"""Extract staged or recent branch changes."""
cmd = ["git", "diff", "origin/main...HEAD"]
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
return result.stdout[:8000] # Cap payload to protect prompt context boundaries
def post_github_pr_comment(comment: str):
pr_number = os.getenv("GITHUB_PR_NUMBER")
repo = os.getenv("GITHUB_REPOSITORY")
github_token = os.getenv("GITHUB_TOKEN")
if not pr_number or not github_token:
print("Skipping PR comment: Missing GITHUB_PR_NUMBER or GITHUB_TOKEN")
return
url = f"https://api.github.com/repos/{repo}/issues/{pr_number}/comments"
headers = {
"Authorization": f"token {github_token}",
"Accept": "application/vnd.github.v3+json"
}
requests.post(url, json={"body": comment}, headers=headers)
def run_ci_audit():
diff_text = get_git_diff()
if not diff_text.strip():
print("No diff detected.")
return
client = CodeGPTPlus(
api_key=os.getenv("CODEGPT_API_KEY"),
org_id=os.getenv("CODEGPT_ORG_ID")
)
agent_id = os.getenv("CODEGPT_AGENT_ID")
prompt = (
"Perform an automated pull request security and style review on this Git diff. "
"Reference our attached codebase graph and architecture standards:\n\n"
f"```diff\n{diff_text}\n```"
)
full_review = ""
for chunk in client.chat_completion(agent_id=agent_id, messages=[{"role": "user", "content": prompt}], stream=True):
full_review += chunk
print("Audit completed successfully.")
post_github_pr_comment(f"### Code GPT Studio Agent Review\n\n{full_review}")
if __name__ == "__main__":
run_ci_audit()
Operational Best Practices & Troubleshooting
| Challenge | Cause | 365Finds Recommended Solution |
|---|---|---|
| HTTP 401 Unauthorized | Missing or malformed API key | Confirm the token was generated in Studio API Keys and passed as Bearer sk-.... |
| HTTP 403 Forbidden | Invalid Organization ID | Include the CodeGPT-Org-Id header matching the organization owning the agent. |
| Agent Hallucinations | Vague instructions or disconnected graph | In Studio, bind the repository graph under Agent Knowledge and click "Start Training". |
| 504 Gateway Timeout | Long code refactoring generation | Always enable stream=True in production backends to receive tokens iteratively. |
| Interaction Rate Limits | High-concurrency batch jobs | Queue requests using Celery or BullMQ; batch diffs into coherent PR summaries. |
By treating Code GPT Studio agents as programmable microservices rather than isolated editor assistants, engineering teams establish consistent architectural governance across their entire software delivery pipeline.
References
- CodeGPT - AI Coding Agent for VS Code, JetBrains and Visual Studio
- Welcome to CodeGPT Documentation – CodeGPT Documentation
- Where do I find my CodeGPT API Key? – CodeGPT Documentation
- AI Agents – CodeGPT Documentation
- What Does the API Plan Include? – CodeGPT Documentation
- CI/CD - Git Commit Reviewer – CodeGPT Documentation
- Code Graphs – CodeGPT Documentation
- Connect CodeGPT to your own Website – CodeGPT Documentation