{
  "openapi": "3.1.0",
  "info": {
    "title": "NoJunk LLM",
    "version": "1.0.0",
    "description": "Pay-per-call, OpenAI-compatible LLM API for agents: POST /v1/chat/completions (Llama 3.3 70B or Qwen 2.5 Coder 32B, up to 32,000 characters of messages, up to 1,024 output tokens, optional JSON mode) and POST /v1/embeddings (BGE-M3, 1,024 dimensions, up to 32 inputs per call). Point any OpenAI client at this base URL and pay per request in USDC on Base via x402: no API key, no account, no rate limits. You are only charged when a valid result is returned.",
    "x-guidance": "OpenAI-compatible LLM API paid per call in USDC on Base via x402 (you are only charged when a valid result is returned; all 4xx/5xx are free). Use it like OpenAI: set base_url to https://nojunk-llm.mick8511.workers.dev/v1 (any api_key value), send the normal JSON bodies, and attach the x402 PAYMENT-SIGNATURE header with an x402 client (for example x402-fetch, or the @x402/fetch wrapper around your HTTP client): the first call without payment returns 402 with the exact requirements. POST /v1/chat/completions {model?: llama-3.3-70b|qwen2.5-coder-32b, messages: [{role: system|user|assistant, content}], max_tokens?: 1-1024, temperature?: 0-2, top_p?, response_format?: {type: \"json_object\"}} -> standard chat.completion object, costs $0.005 per call regardless of length (up to 32000 characters in, 1024 tokens out); \"gpt-4o-mini\" is accepted as an alias of llama-3.3-70b; streaming, tools and image content are not supported (400). POST /v1/embeddings {input: string | string[] (1-32, each <= 8000 chars), model?: bge-m3} -> standard embeddings list (1024 dimensions), costs $0.001 per call. GET /v1/models is free. Best for: agents that need an LLM or embeddings without an API key or account, batch summarization/classification/extraction, RAG indexing and semantic search."
  },
  "servers": [
    {
      "url": "https://nojunk-llm.mick8511.workers.dev"
    }
  ],
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "OpenAI-compatible chat completion (Llama 3.3 70B or Qwen 2.5 Coder 32B)",
        "tags": [
          "AI",
          "LLM",
          "Chat",
          "OpenAI-compatible"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.005000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "llama-3.3-70b",
                      "qwen2.5-coder-32b",
                      "gpt-4o-mini"
                    ],
                    "default": "llama-3.3-70b",
                    "description": "llama-3.3-70b (Llama 3.3 70B, general purpose) or qwen2.5-coder-32b (code). \"gpt-4o-mini\" is accepted as an alias of the default so stock OpenAI client code works unchanged."
                  },
                  "messages": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 200,
                    "items": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "type": "string",
                          "enum": [
                            "system",
                            "user",
                            "assistant"
                          ]
                        },
                        "content": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "role",
                        "content"
                      ]
                    },
                    "description": "The conversation; total content across all messages is capped at 32000 characters (400 above that). Content must be plain strings."
                  },
                  "max_tokens": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1024,
                    "default": 512,
                    "description": "Maximum completion tokens"
                  },
                  "temperature": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 2,
                    "default": 0.7
                  },
                  "top_p": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "maximum": 1,
                    "description": "Nucleus sampling"
                  },
                  "response_format": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "json_object",
                          "text"
                        ]
                      }
                    },
                    "required": [
                      "type"
                    ],
                    "description": "{\"type\": \"json_object\"} forces a JSON object reply (also say \"JSON\" in your prompt)"
                  },
                  "stream": {
                    "type": "boolean",
                    "const": false,
                    "description": "Streaming is not supported; stream: true returns 400"
                  }
                },
                "required": [
                  "messages"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "chatcmpl-<uuid>"
                    },
                    "object": {
                      "type": "string",
                      "const": "chat.completion"
                    },
                    "created": {
                      "type": "integer",
                      "description": "Unix seconds"
                    },
                    "model": {
                      "type": "string",
                      "enum": [
                        "llama-3.3-70b",
                        "qwen2.5-coder-32b"
                      ]
                    },
                    "choices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "type": "integer"
                          },
                          "message": {
                            "type": "object",
                            "properties": {
                              "role": {
                                "type": "string",
                                "const": "assistant"
                              },
                              "content": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "role",
                              "content"
                            ]
                          },
                          "finish_reason": {
                            "type": "string",
                            "enum": [
                              "stop",
                              "length"
                            ]
                          }
                        },
                        "required": [
                          "index",
                          "message",
                          "finish_reason"
                        ]
                      }
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "prompt_tokens": {
                          "type": "integer"
                        },
                        "completion_tokens": {
                          "type": "integer"
                        },
                        "total_tokens": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "prompt_tokens",
                        "completion_tokens",
                        "total_tokens"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "object",
                    "created",
                    "model",
                    "choices",
                    "usage"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (no charge)"
          },
          "402": {
            "description": "Payment Required"
          },
          "413": {
            "description": "Request body larger than 160 KB (no charge)"
          },
          "502": {
            "description": "AI model temporarily unavailable or returned an unusable result (no charge)"
          }
        }
      }
    },
    "/v1/embeddings": {
      "post": {
        "operationId": "createEmbedding",
        "summary": "OpenAI-compatible text embeddings (BGE-M3, 1024 dimensions)",
        "tags": [
          "AI",
          "Embeddings",
          "OpenAI-compatible"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.001000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "input": {
                    "oneOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 8000
                      },
                      {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 32,
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 8000
                        }
                      }
                    ],
                    "description": "Text(s) to embed: one string or up to 32 strings, each at most 8000 characters"
                  },
                  "model": {
                    "type": "string",
                    "enum": [
                      "bge-m3"
                    ],
                    "default": "bge-m3"
                  },
                  "encoding_format": {
                    "type": "string",
                    "enum": [
                      "float"
                    ],
                    "default": "float"
                  }
                },
                "required": [
                  "input"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "type": "string",
                            "const": "embedding"
                          },
                          "index": {
                            "type": "integer"
                          },
                          "embedding": {
                            "type": "array",
                            "items": {
                              "type": "number"
                            },
                            "minItems": 1024,
                            "maxItems": 1024
                          }
                        },
                        "required": [
                          "object",
                          "index",
                          "embedding"
                        ]
                      },
                      "description": "One embedding per input, in input order"
                    },
                    "model": {
                      "type": "string",
                      "const": "bge-m3"
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "prompt_tokens": {
                          "type": "integer",
                          "description": "Approximate (characters / 4)"
                        },
                        "total_tokens": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "prompt_tokens",
                        "total_tokens"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "model",
                    "usage"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (no charge)"
          },
          "402": {
            "description": "Payment Required"
          },
          "413": {
            "description": "Request body larger than 160 KB (no charge)"
          },
          "502": {
            "description": "AI model temporarily unavailable or returned an unusable result (no charge)"
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List available models and their per-call prices (free)",
        "tags": [
          "OpenAI-compatible"
        ],
        "responses": {
          "200": {
            "description": "Model list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "object": {
                            "type": "string",
                            "const": "model"
                          },
                          "owned_by": {
                            "type": "string"
                          },
                          "pricing_usd_per_call": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "object",
                          "owned_by",
                          "pricing_usd_per_call"
                        ]
                      }
                    }
                  },
                  "required": [
                    "object",
                    "data"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}