How to build a code review bot with Vikasit AI
A code review bot reads a diff and posts focused feedback on correctness, security, and maintainability. Hook it into CI or your Git host so every pull request gets an automatic first-pass review.
Recommended model
Vikasit 3 Coder
Tuned for code understanding and structured output, so it produces precise, actionable review comments.
Steps
- 1
Fetch the diff for the pull request (e.g. via the Git host API or git diff).
- 2
Construct a prompt asking for review comments grouped by severity.
- 3
Send the diff to vikasit-3-coder with a system prompt that defines your review standards.
- 4
Parse the model's response into individual comments.
- 5
Post the comments back to the pull request via the host API.
- 6
Run it in CI on every PR; cap diff size and chunk large diffs.
Code
The Vikasit Inference API is OpenAI-compatible, so this uses the standard OpenAI Python SDK pointed at https://api.vikasit.ai/v1.
from openai import OpenAI
client = OpenAI(
base_url="https://api.vikasit.ai/v1",
api_key="sk-vikasit-...", # get one at vikasit.ai/auth
)
def review_diff(diff: str) -> str:
resp = client.chat.completions.create(
model="vikasit-3-coder",
messages=[
{
"role": "system",
"content": (
"You are a senior code reviewer. Report bugs, security issues, "
"and maintainability concerns. One finding per line: "
"severity, location, problem, fix."
),
},
{"role": "user", "content": f"Review this diff:\n{diff}"},
],
)
return resp.choices[0].message.contentBuild your code review bot today
Get an API key and 2M free tokens a day on Vikasit Nova. Pay-as-you-go, no minimums, OpenAI-compatible.