For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Book a demoLog inStart for free
  • Getting started
    • Overview
    • How it works
    • Quickstart
    • Project structure
    • Customer showcase
    • Changelog
  • Configuration
    • Overview
    • Site-level settings
    • Page-level settings
  • Writing content
    • Markdown basics
    • Rich media in Markdown
    • Fern Editor
    • Reusable snippets
  • AI features
    • Overview
    • Fern Writer
    • AI-generated examples
    • Markdown access
      • Overview
      • Customize LLM output
      • Agent directives
      • Analytics and integration
    • MCP server
    • API catalog discovery
      • Overview
        • Overview
          • POSTPost Chat Completion
  • Public API
    • GETJWT from Fern API key
    • GETAlgolia search credentials
    • GETCurrent user information
  • Fern Writer API
    • GETGet Fern Writer Install Link
Checking status...
SOC2Soc 2 Type II
© 2026 Fern • Birch Solutions, Inc., a Postman company

Documentation

SDKsDocsAsk FernCLI Reference

API Definitions

OpenAPIAsyncAPIOpenRPCgRPC

Resources

BlogSupportPricing

Company

Brand KitPrivacy PolicyTerms of Service
LogoLogo
Book a demoLog inStart for free
AI featuresAsk FernAPI referenceChat

Post Chat Completion

||View as Markdown|
POST
/chat/:domain
POST
/chat/:domain
$curl -X POST https://fai.buildwithfern.com/chat/domain \
> -H "Authorization: Bearer <token>" \
> -H "Content-Type: application/json" \
> -d '{
> "messages": [
> {
> "role": "user",
> "content": "Can you explain the benefits of using renewable energy sources?"
> }
> ]
>}'
1{
2 "turns": [
3 {
4 "role": "user",
5 "content": "Can you explain the benefits of using renewable energy sources?"
6 },
7 {
8 "role": "assistant",
9 "content": "Renewable energy sources, such as solar and wind power, provide sustainable and environmentally friendly alternatives to fossil fuels. They help reduce greenhouse gas emissions, decrease air pollution, and promote energy independence."
10 }
11 ],
12 "citations": [
13 "https://www.epa.gov/greenpower/benefits-green-power",
14 "https://www.irena.org/renewable-energy"
15 ]
16}
Was this page helpful?
Previous

Introduction

Next

Create Code Record

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Path parameters

domainstringRequired

Request

This endpoint expects an object.
messageslist of objectsRequired
The messages to use for the chat completion
modelenum or nullOptional
The model to use for the chat completion
Allowed values:
max_tokensinteger or nullOptional100-3500Defaults to 3000

The maximum number of tokens to generate. Note: setting a token count lower than 2000 may result in incomplete responses. You can add a custom system prompt to control the verbosity of the response.

system_promptstring or nullOptional
The system prompt to use for the chat completion
rewrite_queryboolean or nullOptionalDefaults to false
Whether to rewrite the query using query decomposition

Response

Successful Response
turnslist of objects
The conversation turns in the chat completion
citationslist of strings
List of citation strings

Errors

422
Unprocessable Entity Error