Indent AI Pair Programmer

0.1.61 · active · verified Thu Apr 16

Indent is an AI Pair Programmer offering conversational code generation, modification, and explanation. It provides a Python SDK to interact with its services, leveraging an OpenAI-compatible API structure. Currently in early development, its latest version is 0.1.61, with a rapid release cadence due to ongoing development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the IndentClient with your API key and use the chat completions endpoint to generate code. It expects the API key to be set as an environment variable `INDENT_API_KEY`.

import os
from indent import IndentClient

# Ensure your INDENT_API_KEY is set as an environment variable
# Example: export INDENT_API_KEY='your_api_key_here'
api_key = os.environ.get("INDENT_API_KEY", "")

if not api_key:
    raise ValueError("INDENT_API_KEY environment variable not set.")

client = IndentClient(api_key=api_key)

# Example: Generate code using the chat completions API
try:
    response = client.chat.completions.create(
        messages=[
            {"role": "user", "content": "Write a Python function to reverse a string."}
        ]
    )
    print("Generated code:\n", response.choices[0].message.content)
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →