Quickstart

Welcome to SeedofCode AI. Our API is highly compatible with the official OpenAI SDKs, allowing you to use your existing code and tooling by simply changing your baseURL and injecting a SeedofCode AI API key.

1. Get an API Key

Before you can make a request, you need an API key.

  1. Sign up for a free account.
  2. Navigate to the API Keys section in your dashboard.
  3. Click Generate Key. Your new key will start with soc_live_.

[!WARNING] Keep your API key secure. Do not commit it to version control. Keys are only shown once upon creation.

2. Set your Base URL

Configure your client to point to our API instead of OpenAI's default endpoints.

The SeedofCode AI base URL is:

https://api.ai.seedofcode.dev/api

3. Interactive API Tester

Test the API right now in your browser! Head over to the API Playground to enter your API key, edit the raw JSON payload, and see the live response.

4. Make a Request

We support three primary ways to interact with our API: Non-Streaming, Streaming (SSE), and drop-in integration with the official OpenAI SDKs.

4.1 Non-Streaming Request

Generates a response for a given chat conversation. The request blocks until the full response is generated and returns a single JSON object.

import axios from 'axios';

async function main() {
  const response = await axios.post(
    'https://api.ai.seedofcode.dev/api/chat',
    {
      model: 'qwen2.5vl:7b',
      messages: [{ role: 'user', content: 'What is 2+2?' }]
    },
    {
      headers: {
        'Authorization': `Bearer ${process.env.SOC_API_KEY}`,
        'Content-Type': 'application/json'
      }
    }
  );
  console.log(response.data.message.content);
}
main();

4.2 Streaming Request (SSE)

For a faster perceived response time, you can stream the response token-by-token using Server-Sent Events (SSE). Simply add "stream": true to your request payload.

async function streamChat() {
  const response = await fetch('https://api.ai.seedofcode.dev/api/chat/stream', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${process.env.SOC_API_KEY}`
    },
    body: JSON.stringify({
      model: 'qwen2.5vl:7b',
      messages: [{ role: 'user', content: 'Say hello in 5 words.' }],
      stream: true
    })
  });

  const reader = response.body.getReader();
  const decoder = new TextDecoder();
  
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    
    const chunk = decoder.decode(value);
    const lines = chunk.split('\n');
    
    for (const line of lines) {
      if (line.startsWith('data: ') && line !== 'data: [DONE]') {
        const payload = JSON.parse(line.replace('data: ', ''));
        if (payload.message?.content) {
          process.stdout.write(payload.message.content);
        }
      }
    }
  }
}
streamChat();

4.3 Using the OpenAI SDK

If you already use the official OpenAI SDKs, you do not need to write custom REST requests. Just configure the baseURL!

import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "https://api.ai.seedofcode.dev/api",
  apiKey: process.env.SOC_API_KEY, 
});

async function main() {
  const completion = await openai.chat.completions.create({
    model: "qwen2.5vl:7b",
    messages: [
      { role: "system", content: "You are a helpful coding assistant." },
      { role: "user", content: "Write a function to calculate the Fibonacci sequence in Python." },
    ],
  });
  console.log(completion.choices[0].message.content);
}

main();

Available Endpoints

The API provides the following core endpoints:

  • GET /api/models: List all available models.
  • POST /api/chat: Standard chat completion endpoint.
  • POST /api/chat/stream: Streaming chat completion endpoint.
  • POST /api/generate: Generate raw completion (supports stream: true).

You can query the available models like so:

curl https://api.ai.seedofcode.dev/api/models \
  -H "Authorization: Bearer $SOC_API_KEY"

Next Steps