Skip to main content
SynapsAI Cloud provides powerful text generation capabilities through our OpenAI-compatible API endpoints. Our v1/chat/completions and v1/completions endpoints support advanced features including multi-modal inputs, function calling, reasoning effort control, streaming responses, and detailed output analysis.

API Compatibility

Our API is fully compatible with the OpenAI API, supporting the same v1/chat/completions and v1/completions formats. This means you can easily migrate existing OpenAI applications to SynapsAI Cloud.

Message Types and Roles

The chat completions API uses a message-based format where each message has a specific role and content. Understanding these message types is crucial for effective prompting.
The structure of messages also depends on the Jinja chat template of the tokenizer.

Message Roles

  • system: Provides context and instructions to the model about how to behave
  • user: Contains the user’s input or question
  • assistant: Contains the model’s previous responses in a conversation

Message Content Types

Messages can contain different types of content:

Text Content

Multi-modal Content

You can include images, audios and videos in your messages by providing a URL or base64-encoded image data:
Supported image formats include JPEG, PNG, GIF, and WebP. For base64 encoding, use the format: data:image/jpeg;base64,{base64_string}

Conversation Context

Include previous assistant responses to maintain conversation context:

Advanced Parameters

Control the model’s behavior with these key parameters:

Generation Parameters

  • temperature (0.0-2.0): Controls randomness. Lower values make output more deterministic
  • top_p (0.0-1.0): Nucleus sampling parameter
  • top_k (0-100): Top-k sampling parameter
  • max_completion_tokens: Maximum number of tokens to generate
  • stop: Stop generation when these strings are encountered

Output Parameters

  • logprobs: Return log probabilities for tokens
  • top_logprobs: Number of most likely tokens to return at each position

Function Calling and Tools

The chat completions endpoint supports tools, tool_choice, and reasoning_effort. See the dedicated tool calling guide for examples, including how we parse tool calls from model responses and a manual parsing fallback when automatic parsing does not work for your model.

Streaming Responses

Process responses in real-time as they are generated using streaming:

Response Analysis

Understanding Finish Reasons

The finish_reason field indicates why generation stopped:
  • stop: Generation completed normally (hit max_tokens or a stop sequence)
  • length: Generation stopped due to reaching max_tokens

Token Usage and Costs (for per-token pricing)

Monitor your API usage and costs:

Practical Examples

Creative Writing

Generate creative content with specific instructions:

Code Generation

Generate code with specific requirements:

Data Analysis

Analyze and summarize data:

Best Practices

Prompt Engineering

  • Be specific and provide context in system messages
  • Use structured formats for complex tasks
  • Experiment with temperature and other parameters
  • Provide examples in your prompts (few-shot learning)

Error Handling

Always handle API errors gracefully:

Basic Completions API

For simple text generation without conversation context, use the completions endpoint. This endpoint supports everything in the chat completions endpoint, except for the messages parameter that becomes prompt, and the tools parameter that is not supported. We also support providing images, audio, and video files to the completions endpoint.

Example with multi-modal inputs

Some models require a special image token (e.g. <image>) to be placed directly in the prompt to indicate where the image should be referenced. If the model you’re using requires one, we recommend placing it manually in your prompt for best results — for example: "<image>\nDescribe this image.". If no token is present, our backend will attempt to inject it automatically. The same happens for audio and video files.
For quick prototyping and testing, you can also try generating text using the Playground. For deeper insights into the v1/chat/completions and v1/completions endpoints, see our API reference.